Apache Module apxsコマンドで生成されたソースコード
mod_hello_world.c
/* ** mod_hello_world.c -- Apache sample hello_world module ** [Autogenerated via ``apxs -n hello_world -g''] ** ** To play with this sample module first compile it into a ** DSO file and install it into Apache's modules directory ** by running: ** ** $ apxs -c -i mod_hello_world.c ** ** Then activate it in Apache's apache2.conf file for instance ** for the URL /hello_world in as follows: ** ** # apache2.conf ** LoadModule hello_world_module modules/mod_hello_world.so ** <Location /hello_world> ** SetHandler hello_world ** </Location> ** ** Then after restarting Apache via ** ** $ apachectl restart ** ** you immediately can request the URL /hello_world and watch for the ** output of this module. This can be achieved for instance via: ** ** $ lynx -mime_header http://localhost/hello_world ** ** The output should be similar to the following one: ** ** HTTP/1.1 200 OK ** Date: Tue, 31 Mar 1998 14:42:22 GMT ** Server: Apache/1.3.4 (Unix) ** Connection: close ** Content-Type: text/html ** ** The sample page from mod_hello_world.c */ #include "httpd.h" #include "http_config.h" #include "http_protocol.h" #include "ap_config.h" /* The sample content handler */ static int hello_world_handler(request_rec *r) { if (strcmp(r->handler, "hello_world")) { return DECLINED; } r->content_type = "text/html"; if (!r->header_only) ap_rputs("Hello World\n", r); return OK; } static void hello_world_register_hooks(apr_pool_t *p) { ap_hook_handler(hello_world_handler, NULL, NULL, APR_HOOK_MIDDLE); } /* Dispatch list for API hooks */ module AP_MODULE_DECLARE_DATA hello_world_module = { STANDARD20_MODULE_STUFF, NULL, /* create per-dir config structures */ NULL, /* merge per-dir config structures */ NULL, /* create per-server config structures */ NULL, /* merge per-server config structures */ NULL, /* table of config file commands */ hello_world_register_hooks /* register hooks */ };