Fawkes API
Fawkes Development Version
|
22 #include <core/exception.h>
23 #include <webview/rest_api.h>
24 #include <webview/router.h>
45 router_{std::make_shared<WebviewRouter<Handler>>()}
67 std::map<std::string, std::string> path_args;
68 Handler handler = router_->find_handler(request->
method(), rest_url, path_args);
70 params.set_path_args(std::move(path_args));
72 std::unique_ptr<WebReply> reply = handler(request->
body(), params);
73 return reply.release();
87 router_->add(method, path, handler);
96 pretty_json_ = pretty;
const std::string & name() const
Get name of component.
Web request meta data carrier.
std::function< std::unique_ptr< WebReply >std::string, WebviewRestParams &)> Handler
REST API call handler function type.
WebReply * process_request(const WebRequest *request, const std::string &rest_url)
Process REST API request.
const std::map< std::string, std::string > & get_values() const
Get map of GET values.
Fawkes library namespace.
Method
HTTP transfer methods.
REST parameters to pass to handlers.
const std::string & body() const
Get body of request.
WebviewRestApi(const std::string &name, fawkes::Logger *logger)
Constructor.
Method method() const
Get HTTP transfer method.
void set_pretty_json(bool pretty)
Enable or disable pretty JSON printing globally.
A NULL pointer was supplied where not allowed.
void add_handler(WebRequest::Method method, std::string path, Handler handler)
Add handler function.