MCPcopy Create free account
hub / github.com/Stiffstream/restinio / handler

Function handler

dev/sample/hello_world_basic/main.cpp:6–24  ·  view source on GitHub ↗

Create request handler.

Source from the content-addressed store, hash-verified

4
5// Create request handler.
6restinio::request_handling_status_t handler( const restinio::request_handle_t& req )
7{
8 if( restinio::http_method_get() == req->header().method() &&
9 req->header().request_target() == "/" )
10 {
11 req->create_response()
12 .append_header( restinio::http_field::server, "RESTinio hello world server" )
13 .append_header_date_field()
14 .append_header( restinio::http_field::content_type, "text/plain; charset=utf-8" )
15 .set_body( fmt::format(
16 RESTINIO_FMT_FORMAT_STRING( "{}: Hello world!" ),
17 restinio::fmtlib_tools::streamed( req->remote_endpoint() ) ) )
18 .done();
19
20 return restinio::request_accepted();
21 }
22
23 return restinio::request_rejected();
24}
25
26int main()
27{

Callers

nothing calls this directly

Calls 8

streamedFunction · 0.85
request_acceptedFunction · 0.85
request_rejectedFunction · 0.85
methodMethod · 0.80
request_targetMethod · 0.80
create_responseMethod · 0.80
doneMethod · 0.45
remote_endpointMethod · 0.45

Tested by

no test coverage detected