EndpointConfig<'E> Type
Configuration for Route.endpoints - bundles all extraction settings.
This record combines all the pieces needed for route extraction:
Precondition extractors for auth/validation Custom parsers for domain types Error handling functions
Example
let config: EndpointConfig<AppError> = {
Preconditions = [ yield! Extractor.precondition<UserId, _> requireAuth ]
Parsers = [ Extractor.parser<Slug> slugParser ]
MakeError = fun msg -> BadRequest msg
CombineErrors = fun errors -> errors |> List.head
ToErrorResponse = fun e -> Response.withStatusCode 400 >> Response.ofPlainText (string e)
}
let endpoints = Route.endpoints config routeHandler
module List from Microsoft.FSharp.Collections
--------------------
type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T with get member IsEmpty: bool with get member Item: index: int -> 'T with get ...
val string: value: 'T -> string
--------------------
type string = System.String
Record fields
| Record Field |
Description
|
Full Usage:
CombineErrors
Field type: 'E list -> 'E
|
Reduces multiple field errors into one when more than one field fails.
|
Full Usage:
MakeError
Field type: string -> 'E
|
Converts a route/query parsing error message (string) into your error type.
|
|
Parsers for custom types in route/query parameters. Create with Extractor.parser. Built-in types are handled automatically.
|
|
Extractors for PreCondition<'T> and OverridablePreCondition<'T> fields. Create with Extractor.precondition (covers both types).
|
Full Usage:
ToErrorResponse
Field type: 'E -> HttpHandler
|
Converts the final error into an HTTP response sent to the client.
|
Falco.UnionRoutes