File: example_plugin.c

package info (click to toggle)
uwsgi 2.0.31-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,564 kB
  • sloc: ansic: 87,066; python: 7,004; cpp: 1,133; java: 708; perl: 678; sh: 585; ruby: 555; makefile: 148; xml: 130; cs: 121; objc: 37; php: 28; erlang: 20; javascript: 11
file content (34 lines) | stat: -rw-r--r-- 827 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <uwsgi.h>

extern struct uwsgi_server uwsgi;

static int uwsgi_example_init(){
	uwsgi_log("i am the example plugin initialization function\n");
	return 0;
}

static int uwsgi_example_request(struct wsgi_request *wsgi_req) {

	uwsgi_response_prepare_headers(wsgi_req, "200 OK", 6);
	uwsgi_response_add_header(wsgi_req, "Content-type", 12, "text/html", 9);
	uwsgi_response_write_body_do(wsgi_req, "<h1>Hello World</h1>", 20);

	return UWSGI_OK;
}


static void uwsgi_example_after_request(struct wsgi_request *wsgi_req) {
	uwsgi_log("i am the example plugin after request function\n");
}


struct uwsgi_plugin example_plugin = {

        .name = "example",
        .modifier1 = 250,
        .init = uwsgi_example_init,
        .request = uwsgi_example_request,
        .after_request = uwsgi_example_after_request,

};