Skip to content

Commit

Permalink
Add better path handling for controller index action
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof-Cieslak committed Jan 28, 2018
1 parent 7880b73 commit a37c360
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Saturn/Controller.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down

0 comments on commit a37c360

Please sign in to comment.