From a37c36089ad01e4e22030f4e16a492769235b9d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Cie=C5=9Blak?= Date: Sun, 28 Jan 2018 23:41:05 +0100 Subject: [PATCH] Add better path handling for controller index action --- src/Saturn/Controller.fs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Saturn/Controller.fs b/src/Saturn/Controller.fs index ba69b3e2..07ecf600 100644 --- a/src/Saturn/Controller.fs +++ b/src/Saturn/Controller.fs @@ -44,7 +44,6 @@ module Controller = let lst = choose [ yield GET >=> choose [ - if state.Index.IsSome then yield route "/" >=> (fun _ ctx -> state.Index.Value(ctx)) if state.Add.IsSome then yield route "/add" >=> (fun _ ctx -> state.Add.Value(ctx)) if state.Edit.IsSome then match typ with @@ -64,6 +63,9 @@ module Controller = | Int64 -> yield routef "/%d" (fun input _ ctx -> state.Show.Value(ctx, unbox<'Key> input) ) | Float -> yield routef "/%f" (fun input _ ctx -> state.Show.Value(ctx, unbox<'Key> input) ) | Guid -> yield routef "/%O" (fun input _ ctx -> state.Show.Value(ctx, unbox<'Key> input) ) + if state.Index.IsSome then + yield route "" >=> (fun _ ctx -> ctx.Request.Path <- PathString(ctx.Request.Path.ToString() + "/"); state.Index.Value(ctx)) + yield route "/" >=> (fun _ ctx -> state.Index.Value(ctx)) ] yield POST >=> choose [ if state.Create.IsSome then yield route "/" >=> (fun _ ctx -> state.Create.Value(ctx))