libtasks Documentation
1.6
Main Page
Namespaces
Classes
Files
File List
File Members
uwsgi/uwsgi_handler.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2013-2014 ADTECH GmbH
3
* Licensed under MIT (https://github.com/adtechlabs/libtasks/blob/master/COPYING)
4
*
5
* Author: Andreas Pohl
6
*/
7
8
#include <
tasks/dispatcher.h
>
9
#include <
tasks/net/acceptor.h
>
10
11
#ifdef PROFILER
12
#include <google/profiler.h>
13
#endif
14
15
#include "
uwsgi_handler.h
"
16
#include "
stats.h
"
17
18
bool
uwsgi_handler::handle_request
() {
19
// Do something with the url for example
20
// const std::string& url = request().var("REQUEST_URI");
21
// Or print all incoming variables
22
// request().print_vars();
23
24
// Now send back a response
25
response
().
set_status
(
"204 No Content"
);
26
send_response
();
27
28
stats::inc_req
();
29
30
return
true
;
31
}
32
33
int
main
(
int
argc,
char
** argv) {
34
#ifdef PROFILER
35
ProfilerStart(
"uwsgi_server.prof"
);
36
#endif
37
stats
s;
38
tasks::net::acceptor<uwsgi_handler>
srv(12345);
39
auto
tasks = std::vector<tasks::task*>{&srv, &s};
40
tasks::dispatcher::instance
()->run(tasks);
41
#ifdef PROFILER
42
ProfilerStop();
43
#endif
44
return
0;
45
}
acceptor.h
tasks::dispatcher::instance
static std::shared_ptr< dispatcher > instance()
Definition:
dispatcher.h:75
tasks::net::uwsgi_task::response
http_response & response()
Definition:
uwsgi_task.h:55
main
int main(int argc, char **argv)
Definition:
uwsgi/uwsgi_handler.cpp:33
uwsgi_handler::handle_request
bool handle_request()
Definition:
thrift_server/uwsgi_handler.cpp:25
tasks::net::acceptor
Definition:
acceptor.h:26
tasks::net::http_response::set_status
void set_status(std::string status)
Definition:
http_response.h:23
tasks::net::uwsgi_task::send_response
void send_response()
Send the resonse back.
Definition:
uwsgi_task.h:67
uwsgi_handler.h
dispatcher.h
stats
Definition:
echoserver.h:19
stats::inc_req
static void inc_req()
Definition:
echoserver.h:25
stats.h
examples
uwsgi
uwsgi_handler.cpp
Generated by
1.8.6