Skip to content

Commit e2855b7

Browse files
NinoFlorisKrzysztof-Cieslak
authored andcommitted
Await before adding result to Items.["RequestModel"] fixes #70 (#74)
1 parent d65d47b commit e2855b7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Saturn/Pipelines.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,18 @@ module PipelineHelpers =
184184
///Tries to model from request and puts model into `Items.RequestModel`. If it won't be called content can be fetched using `Context.Controller` helpers.
185185
///It won't crash the pipelines if fetching failed.
186186
///It optionally takes custom culture name as arguments.
187-
let fetchModel<'a> culture (nxt : HttpFunc) (ctx : HttpContext) : HttpFuncResult =
187+
let fetchModel<'a> culture (nxt : HttpFunc) (ctx : HttpContext) : HttpFuncResult = task {
188188
let clt = culture |> Option.map System.Globalization.CultureInfo.CreateSpecificCulture
189189
try
190-
let mdl =
190+
let! mdl =
191191
match clt with
192192
| Some c -> ctx.BindModelAsync<'a>(c)
193193
| None -> ctx.BindModelAsync<'a>()
194194
ctx.Items.["RequestModel"] <- mdl
195195
with
196196
| _ -> ()
197-
nxt ctx
197+
return! nxt ctx
198+
}
198199

199200
let internal fetchUrl (nxt : HttpFunc) (ctx : HttpContext) : HttpFuncResult =
200201
if not (ctx.Items.ContainsKey "RequestUrl") then

0 commit comments

Comments
 (0)