PlugImageProcessing.Middleware protocol (plug_image_processing v0.9.1)
View SourceProtocol for implementing middleware in the image processing pipeline.
Middleware can be used to add security checks, modify headers, validate requests, or perform any other processing on the connection before or after image operations.
Summary
Functions
Determines if this middleware should be enabled for the given connection.
Executes the middleware logic on the connection.
Types
@type t() :: struct()
Functions
@spec enabled?(t(), Plug.Conn.t() | nil) :: boolean()
Determines if this middleware should be enabled for the given connection.
This allows conditional activation of middleware based on configuration or request parameters.
Parameters
middleware- The middleware struct containing configurationconn- The Plug.Conn struct to check (may be nil during initialization)
Returns
trueif the middleware should run,falseotherwise
@spec run(t(), Plug.Conn.t()) :: Plug.Conn.t()
Executes the middleware logic on the connection.
This function should process the connection and return a potentially modified connection. It may halt the connection if validation fails.
Parameters
middleware- The middleware struct containing configurationconn- The Plug.Conn struct to process
Returns
- Modified Plug.Conn struct (may be halted)