Edda.Middleware
Small wrapper-style middleware helpers.
Edda does not define a Middleware type. These helpers cover the common
pure request/response transforms and panic recovery; more advanced behavior
is usually an ordinary wrapper function or an effect handler.
Types
GzipStream
opaque type GzipStreamCompressionOptions
record CompressionOptions {
min_size: Int
}Options for response compression middleware.
Functions
use_request
fun use_request : Request -> Request -> Request -> Response needs {..e} -> Request -> Response needs {..e}Transform the request before passing it to a handler.
use_response
fun use_response : Response -> Response -> Request -> Response needs {..e} -> Request -> Response needs {..e}Transform the response produced by a handler.
default_compression_options
fun default_compression_options : CompressionOptionsDefault compression policy.
Buffered responses smaller than 1024 bytes are left alone. Streamed responses do not have a known size up front, so eligible streams are compressed whenever the client accepts gzip.
use_compression
fun use_compression : Request -> Response needs {..e} -> Request -> Response needs {..e}Compress eligible responses with gzip when the request accepts it.
use_compression_with
fun use_compression_with : CompressionOptions -> Request -> Response needs {..e} -> Request -> Response needs {..e}Compress eligible responses with explicit compression options.
default_panic_response
fun default_panic_response : String -> ResponseDefault panic response for use_panic_recovery.
This includes the panic message, which is useful during development. Apps can pass their own recovery function to hide details in production.
use_panic_recovery
fun use_panic_recovery : String -> Response -> Request -> Response needs {..e} -> Request -> Response needs {..e}Catch panics from the inner handler and turn them into responses.
This is opt-in. Place timing/logging wrappers outside this one if they should observe recovered 500 responses.