::
httpservice
¶Inherits from n3rv::service
Public Functions
serve_file
(const char *path)¶Opens file on host and retrieves its content.
path
: File’s path. init_http
(std::string http_listen_addr, int http_listen_port)¶Initializes http service on listen_addr:port.
http_listen_addr
: IP to bind http service on. http_listen_port
: TCP port to bind http service on. run_http
()¶Starts the http service once initialized.
run_http_async
()¶Starts the http service, in a dedicated thread.
attach_http
(std::string uri, httpcb cb)¶HTTP URI Callback binding method.
uri
: URI address to attach callback to. cb
: callback pointer. register_dir
(std::string uri, std::string path)¶Adds a new FS directory to recursively serve files that are inside.
uri
: root URI of files to serve. path
: Filesystem path of directory to serve. Public Static Functions
http_gen_callback
(evhttp_request *req, void *objref)¶General purpose callback, mainly stands for file serving.
req
: libevent’s request pointer. objref
: this backward pointer. http_callback
(evhttp_request *req, void *objref)¶Default HTTP callback (for testing and example)
req
: request object coming from libevent. objref
: Calling object’s back ref.