vimwiki/tech/Crow.wiki

53 lines
1.1 KiB
Plaintext

= Crow =
Crow is a fast, [[flask]]-like C++ microframework
== Apps ==
Crow provides a `crow::App` type that comes in two flavors
* `crow::SimpleApp`
* no middle ware
* `crow::App<m1, m2>`
* uses m1, m2, etc. middleware
Some other usefule interfaces
* `bindaddr(192.168.1.144)`
* takes an IP addr to bind to
* `.port(443)`
* takes an int port to listen on
* `.multithreaded()`
* enable multithreaded request handling
* `.run()`
* Run the app
* Run is blocking, use `run_async` for non blocking
== Routes ==
Routes assign URLs to function calls. To assign a route, use the macro
`CROW_ROUTE(app, url)`
where,
* `app` is the app class to assign the route to
* `url` is the relative path is assigned to the route
* paths can take paramaters
* `/hello/<int>`
* paramaters can be
* `int`
* `uint`
* `double`
* `string`
* `path`
HTTP methods can also be changed on routes via the `.method()` call, appended
to the `CROW_ROUTE` macro.
HTTP methods include
* `crow::HTTPMethod::GET`
* `crow::HTTPMethod::PATCH`
* `crow::HTTPMethod::POST`
=== Catchall route ===