messua/mware
Some basic middlware layers.
See the documentation for
Layer
and stack()
for some examples of how to put these together and use them.
Types
Functions
pub fn make_log_layer(
target: LogTarget,
) -> fn(
MRequest(a),
fn(MRequest(a)) -> Result(Response(ResponseData), Err),
) -> Result(Response(ResponseData), Err)
Return a Layer
function that loggs to the specified target.
Currently, logging to a file opens the file for append each time. This is clearly not the most efficient method, but I don’t know enough Erlang yet to do better.
TODO: Learn some Erlang and do better.
Safety
If you specify a path that cannot be written to, the server will crash upon startup.
pub fn make_static_header_layer(
header_name: String,
header_value: String,
) -> fn(
MRequest(a),
fn(MRequest(a)) -> Result(Response(ResponseData), Err),
) -> Result(Response(ResponseData), Err)
Adds the given header to every outgoing request.