Expand description
Defines types for handlers, the primary building block of a Gotham application.
A function can be used directly as a handler using one of the default implementations of
Handler, but the traits can also be implemented directly for greater control. See the
Handler trait for some examples of valid handlers.
Structs§
- DirHandler
- Represents a handler for any files under a directory.
- File
Handler - Represents a handler for a single file.
- File
Options - Options to pass to file or dir handlers. Allows overriding default behaviour for compression, cache control headers, etc.
- File
Path Extractor - Responsible for extracting the file path matched by the glob segment from the URL.
- Handler
Error - Describes an error which occurred during handler execution, and allows the creation of a HTTP
Response.
Traits§
- Handler
- A
Handleris an asynchronous function, taking aStatevalue which represents the request and related runtime state, and returns a future which resolves to a response. - Into
Handler Future - Represents a type which can be converted into the future type returned by a
Handler. - Into
Response - Represents a type which can be converted to a response. This trait is used in converting the return type of a function into a response.
- MapHandler
Error - This trait allows you to convert a
Result’sErrcase into a handler error with the given status code. This is handy if you want to specify the status code but still use the?shorthand. - MapHandler
Error Future - This trait allows you to convert a
Result’sErrcase into a handler error with the given status code. This is handy if you want to specify the status code but still use the?shorthand. - NewHandler
- A type which is used to spawn new
Handlervalues. When implementing a customHandlertype, this is used to define how instances of theHandlerare created.
Type Aliases§
- Handler
Future - A type alias for the trait objects returned by
HandlerService. - Handler
Result - A type alias for the results returned by async fns that can be passed to to_async.
- Simple
Handler Result - A type alias for the results returned by async fns that can be passed to to_async_borrowing.