forked from nginx/ngx-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathngx_http_rust_module.c
92 lines (72 loc) · 1.93 KB
/
ngx_http_rust_module.c
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* @file ngx_rust.c
* @author Sehyo Chang <sehyo@nginx.com>
* @date
*
* @brief Dummy module
*
* @section LICENSE
*
* Copyright (C) 2011 by Nginx
*
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
/**
* @brief element mixer configuration
*/
typedef struct {
ngx_str_t name; /**< test name */
} ngx_http_rust_main_conf_t;
static void *ngx_http_rust_create_main_conf(ngx_conf_t *cf);
/*
* dummy rust
*/
static ngx_command_t ngx_http_rust_commands[] = {
{
ngx_string("rust"), /* dummy directive */
NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, // server takes 1 //
ngx_conf_set_str_slot, /* configuration setup function */
NGX_HTTP_MAIN_CONF_OFFSET,
offsetof(ngx_http_rust_main_conf_t, name),
NULL
},
ngx_null_command /* command termination */
};
/* The module context. */
static ngx_http_module_t ngx_http_rust_module_ctx = {
NULL, /* preconfiguration */
NULL, /* postconfiguration */
ngx_http_rust_create_main_conf, /* create main configuration */
NULL, /* init main configuration */
NULL, /* create server configuration */
NULL, /* merge server configuration */
NULL,
NULL
};
/* Module definition. */
ngx_module_t ngx_http_rust_module = {
NGX_MODULE_V1,
&ngx_http_rust_module_ctx, /* module context */
ngx_http_rust_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
NULL, /* init master */
NULL, /* init module */
NULL, /* init process */
NULL, /* init thread */
NULL, /* exit thread */
NULL, /* exit process */
NULL, /* exit master */
NGX_MODULE_V1_PADDING
};
static void *ngx_http_rust_create_main_conf(ngx_conf_t *cf)
{
ngx_http_rust_main_conf_t *conf;
ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "setting up main config");
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_rust_main_conf_t));
if (conf == NULL) {
return NULL;
}
return conf;
}