Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TokenRouter needs explicit GET when POST is used #158

Closed
forki opened this issue Nov 30, 2017 · 3 comments
Closed

TokenRouter needs explicit GET when POST is used #158

forki opened this issue Nov 30, 2017 · 3 comments
Labels
bug Reproducible bug
Milestone

Comments

@forki
Copy link
Contributor

forki commented Nov 30, 2017

Reminder for @gerardtoconnor ;-)

sent you actual routes in screenshot. It's along the lines of:

 router notfound [
      subRoute "/api" [
           // get routes
           route "/hey" f
           POST [
              route "/there" f2
           ]
 ]

not working. but following is:

 router notfound [
      subRoute "/api" [
           GET [
               route "/hey" f
           ]
           POST [
              route "/there" f2
           ]
 ]
@dustinmoris dustinmoris added the bug Reproducible bug label Nov 30, 2017
@dustinmoris dustinmoris added this to the RC1 milestone Nov 30, 2017
@gerardtoconnor
Copy link
Member

I'll look into this, thanks for raising.

The issue relates to it being able to partially match the non-filtered root before realizing it's a dead-end but there may have been a route possible in filtered routes earlier in the tree.

There are a few ways to fix but I want to make sure it's performant & clean so please bear with me and use the explicit route filtering as you have for now thanks.

@gerardtoconnor
Copy link
Member

@forki I know breaking changes are annoying but when I created the method filter functions I overlooked the fact that many people like to do filter as last leg in chain eg:

router notfound [
      subRoute "/api" [
           subRoute "/hey" [
                GET f1
                POST f2
           ]
           POSTGRP [
              route "/there" f3
           ]
 ]

So I am wondering how I handle it and if I have two separate functions for each method eg for GET:

  1. GET : HttpHandler -> Node -> Node
  2. GETGRP : (Node -> Node) list -> Node

not changing anything yet but along with this bug fix want to make sure fixes against this issue as

router notfound [
      subRoute "/api" [
           GET [ 
                route "/hey" f1 
           ]
           POST [ 
                route "/hey" f2
           ]
           POST [
              route "/there" f3
           ]
 ]

Is bit repetitive and frustrating for user having to write route "/hey" twice?

@dustinmoris
Copy link
Member

Moved to giraffe-fsharp/Giraffe.TokenRouter#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reproducible bug
Projects
None yet
Development

No branches or pull requests

3 participants