File: notfound.c

package info (click to toggle)
uwsgi 2.0.31-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,624 kB
  • sloc: ansic: 87,072; python: 7,010; 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 (29 lines) | stat: -rw-r--r-- 740 bytes parent folder | download | duplicates (9)
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
#include <uwsgi.h>

static int uwsgi_notfound_log_enabled = 0;

struct uwsgi_option uwsgi_notfound_options[] = {
	{"notfound-log", no_argument, 0, "log requests to the notfound plugin", uwsgi_opt_true, &uwsgi_notfound_log_enabled, 0},
	{NULL, 0, 0, NULL, NULL, NULL, 0},
};

static int uwsgi_request_notfound(struct wsgi_request *wsgi_req) {
	if (uwsgi_parse_vars(wsgi_req)) {
		return -1;
	}
	uwsgi_404(wsgi_req);
	return UWSGI_OK;
}

static void uwsgi_notfound_log(struct wsgi_request *wsgi_req) {
	if (uwsgi_notfound_log_enabled) {
		log_request(wsgi_req);
	}
}

struct uwsgi_plugin notfound_plugin = {
	.name = "notfound",
	.options = uwsgi_notfound_options,
	.request = uwsgi_request_notfound,
	.after_request = uwsgi_notfound_log,
};