From 24c9d9915b0c7879369bbeb4ee7ae12120123405 Mon Sep 17 00:00:00 2001 From: Tyler Perkins Date: Thu, 28 Apr 2022 15:00:01 -0400 Subject: [PATCH] Update for 28-04-22 15:00 --- tech/Crow.wiki | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tech/Crow.wiki b/tech/Crow.wiki index eadf5d2..def7641 100644 --- a/tech/Crow.wiki +++ b/tech/Crow.wiki @@ -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` of values if key in query string is of + format `key[]=val1&key[]=val2` +* `get_dict(name)` + * return a `std::unordered_map` 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`. +