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

Can a SubRouteF concept work? #220

Closed
TWith2Sugars opened this issue Feb 6, 2018 · 7 comments
Closed

Can a SubRouteF concept work? #220

TWith2Sugars opened this issue Feb 6, 2018 · 7 comments

Comments

@TWith2Sugars
Copy link

I found my self in a situation using saturnframwork where I needed to "forward" to a url such as "/api/%i"
I started to add forwardf to saturn by looking at how forward was implemented and realized it ultimately called subRoute.

I couldn't find an existing subRouteF functions and I attempted to add it my self (by seeing how subroute and route/routef work) but I really have no idea what I'm doing.

Is this even possible in how giraffe works?

@gerardtoconnor
Copy link
Member

Hi,

A subRoute is just a common url stub for a collection of routes with the same prefix eg /api/

If you want to have a /api/%i that will parse after the api, and only one route is using this pattern, it's just a route(f), not a subroute as there is no grouping. If you are grouping routes please provide some examples but from above, and in general, subRouteF doesn't make sense as you cannot group routes by a prefix that is unknown (the unknown format parser)

@TWith2Sugars
Copy link
Author

I see, that makes sense. The issue is really down to how I structure my app.

Overall I'm attempting to get saturn's forward to work like it's getf. I'll create an issue there and see if I can figure out to work it.

@gerardtoconnor
Copy link
Member

If you are parsing the argument directly after api, instead of having more child routes that you probably do not want to use the "forward" but instead, just a plain getf as is is just one routing function, not many.

@dustinmoris
Copy link
Member

In #223 someone had actually a valid use case for subRoutef. A subRoutef http handler has now been added and will be released with the next version of Giraffe.

@TWith2Sugars
Copy link
Author

Thanks! I was getting no where trying to add it in saturn.

@TWith2Sugars
Copy link
Author

Do you have a roadmap for when the next version is released?

@dustinmoris
Copy link
Member

I am aiming for some point this week!

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

No branches or pull requests

3 participants