Using Giraffe is it possible to pass a value to the next HttpHandler

84 views Asked by At

I want to be able to chain handlers where the first performs model binding on the POST payload and the subsequent handlers operate on that payload like described below.


    let extractXml : HttpHandler =
        fun (next: HttpFunc) (ctx: HttpContext) ->
            task {
                let! xml = ctx.ReadBodyBufferedFromRequestAsync()
                // ?? how to pass to the next handler?
            }


    let webApp =
        choose [
            POST >=> 
                choose [
                    routeCix "/" >=> extractXml >=> v1Handler >=> v2Handler >=> Successful.ACCEPTED String.Empty                ]
            setStatusCode 404 >=> text "Not Found" ]

The samples all show the HttpHandler being a complete unit of work. What I was unsure of it whether this was due to a desire to have a straightforward example or is required by giraffe.

0

There are 0 answers