rama::layer

Function layer_fn

pub fn layer_fn<T>(f: T) -> LayerFn<T>
Expand description

Returns a new LayerFn that implements Layer by calling the given function.

The Layer::layer method takes a type implementing Service and returns a different type implementing Service. In many cases, this can be implemented by a function or a closure. The LayerFn helper allows writing simple Layer implementations without needing the boilerplate of a new struct implementing Layer.