ElJef HTTP
ElJef HTTP is a Golang package for quickly setting up an HTTP service in a
new project. This HTTP server does not target performance. Instead, it targets
ease of implementation for small projects.
This package sets up a server that can take input as anything, but only
returns data as JSON. This is perfect for writing bots with an admin interface,
small web services, or glue services.
Concepts
Distributor
A distributor is the core HTTP endpoint handler. It provides the
ServeHTTP
method used for talking to an end point.
When ServeHTTP
is called, the distributor automatically resolves the remote
callers address, starting with reverse proxy headers X-Real-IP
and
X-Forwarded-For
and then falls back to the HTTP Server provided
Remote-Addr
.
Logger
The Distributor then creates a new child logger with its own ID, holding its
parents ID as well. This logger can be passed through all execution paths in
a service, allowing for auditing and tracing.
Context
The Distributor creates a new context for each incoming request. The Context
is passed down through all middleware for the Distributor, and the final end
point handler. Data to be passed between middlewares and the final handler can
store and retrieve data in the context.
Middlewares
Registered middlewares are called in order, having the context passed to them.
Middlewares return a bool signaling if they executed correctly.
Handler
The final handler processes the request and writes and return data to the
context. The Distributor will handle responding to the client based on the
return code.
TODO
Expand documentation