Name
Handlers
Synopsis
handler_rec aModuleHandlers[]; [1.3]
The definition of a handler_rec
can be found in
http_config.h (1.3):
typedef struct { char *content_type; int (*handler)(request_rec *); } handler_rec;
In 2.0, the handlers are simply registered with a hook in the usual way and are responsible for checking the content type (or anything else they want to check) in the hook.
Finally, we are ready to handle the request. The core now searches
through the modules’ handler entries, looking for an
exact match for either the handler type or the MIME type, in that
order (that is, if a handler type is set, that is used; otherwise,
the MIME type is used). When a match is found, the corresponding
handler function is called. This will do the actual business of
serving the user’s request. Often you
won’t want to do this, because
you’ll have done the work of your module earlier,
but this is the place to run your Java, translate to Swedish, or
whatever you might want to do to serve actual content to the user.
Most handlers either send some kind of content directly (in which
case, they must remember to call ap_send_http_header(
)
before sending the content) or use one of the internal
redirect methods (e.g., internal_redirect()
).
mod_status.c only implements a handler; Example 21-22 (1.3) shows the handler’s table.
Example
handler_rec status_handlers[] = { { STATUS_MAGIC_TYPE, status_handler }, { "server-status", status_handler }, { NULL } };
We don’t show the ...
Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.