Update for 28-04-22 15:00

This commit is contained in:
Tyler Perkins 2022-04-28 15:00:01 -04:00
parent 6be2eaaa2c
commit 24c9d9915b

View File

@ -73,6 +73,8 @@ can only READ from a `rvalue`. To write to one, convert to `wvalue`. This is
done via `crow::json::wvalue wval(rval);`, where `rval` is the `rvalue` you
want to convert.
Assign values to a `crow::json` value via the index operator.
You can return a `wvalue` in a route handler, and the type is automatically
casted and the header Content-Type header is automatically set to
`application/json`.
@ -84,4 +86,37 @@ See [[Mustache]]
An HTML page template with mustache tags is loaded into a
`crow::mustache::template_t`. The file needs to be in a templates directory.
These templates are read at runtime, and therefore need to be available to the
binary.
binary. A global templates directory can be set via
`crow::mustache::set_global_base("new_template_dir")`.
== Query Strings ==
A query string is part of a URL that has a `?` char at the end, with the same
format as a POST request. In a handler you will have access to a
`crow::request::url_params`. It supports
* `get(name)`
* get `name` and return value as a `char*`
* if not found return `nullptr`
* `get_list(name)`
* return a `std::vector<std::string>` of values if key in query string is of
format `key[]=val1&key[]=val2`
* `get_dict(name)`
* return a `std::unordered_map<std::string, std::string>` of values for dict
style query string
All of the above `get_*` operation has a `pop_*` counterpart that modifies the
object. Note that the provided `crow::request::url_params` object is `const` by
default, and therefore you will not be able to call `pop_*` on it unless a copy
is made.
== Compression ==
Compression is disabled by default. To enable it be sure to include
`-DCROW_ENABLE_COMPRESSION` in your compilation calls. Then call
`use_compression(crow::compression::algorithm)` on your `crow::App` or
`crow::SimpleApp` object. Also be sure to include ZLIB as a dependency.
The compression algorithms provided include
`crow::compression::algorithm::DEFLATE` and
`crow::compression:algorithm::GZIP`.