libtasks Documentation  1.6
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 
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 
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;
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 }
static std::shared_ptr< dispatcher > instance()
Definition: dispatcher.h:75
http_response & response()
Definition: uwsgi_task.h:55
int main(int argc, char **argv)
void set_status(std::string status)
Definition: http_response.h:23
void send_response()
Send the resonse back.
Definition: uwsgi_task.h:67
static void inc_req()
Definition: echoserver.h:25