Comments (10)
I'd like to see a 400 Bad Request: foo is not in a format valid for a SSN: xxx-xx-xxxx
in response to this, ideally.
from rho.
Documentation is certainly a thing we can improve all around.
I think there is a case to be made for a situation like this but it requires a bit of work in the PathTree
. In particular, the matchString
method is responsible to checking/parsing the route. Right now it returns a HList
of successful parameters on a successful match, or null
. I think this could be replaced with a RouteResult[HList]
without sacrificing performance and allowing the route to continue to 'fall through' while preserving the fact that one failed and perhaps returning a 400 Bad Request.
On the other hand, when I think of a route I think that a path should either match or not, and I'd preserve the 'Bad Request' for a query or headers based parameter. I'm willing to have strong opinions about it one way or the other?
from rho.
Maybe the 400 is more appropriate for improperly formatted query params, not routes that we've dictated must be parseable as a some kind of data type?
from rho.
@LeifW, that my knee jerk feeling, but I'm far from an expert.
As a counter example, I think a more traditional framework would offer up the strings and it would be up to the route to determine if they are valid or not, in which case they would probably return a 400.
Any thoughts?
from rho.
I asked around. "RESTfulness calls for a 404", since a non-404 response would imply the existence of a resource there. I think I see that behavior elsewhere. Maybe if you want better error messages on these kind of keys, have them as a query param, instead? :/
But, maybe we could still make the body of the 404 more descriptive: "close, but no cigar"?
from rho.
Maybe I'm relatively new to REST, I would love to see more references on what kinds of things should be path params vs query params -- but "query params are used when you want more detailed errors" doesn't scratch the itch for me :-)
My gut sort of says "query params are optional params", but I know that isn't quite right either.
Not sure if there'd be a general way to say "404 because this happened during parsing". And even if there were a way, I don't know if it would be a good idea in general. But maybe during development? But supporting multiple modes creates even more work!
from rho.
I just realized I don't care at all what the HTTP code is, I just wished for debugging clues.
from rho.
Maybe this is a good case for simply adding some debug logging during path evaluation?
from rho.
That could work. Are there already some logging facilities to plug into?
I mean, a partial solution could also just be "remember how path var parsing works, now that you know", but if there's an easy way to get warnings, why not.
from rho.
I don't believe the PathTree
type has any logging in it yet. I don't see a reason not to add it. We've been using log4s which has been really nice.
from rho.
Related Issues (20)
- Provide example using the Swagger UI Webjar HOT 1
- Got Error with http4s-scala-xml HOT 2
- NoSuchMethodError from rho 0.20.0-M1 HOT 2
- StringParser for value classes HOT 4
- Broken Links/URLs in `README.md` in branch `master` HOT 1
- Where is RhoService? HOT 2
- Feature Idea: Serving swagger in YAML
- Feature Idea: Customisable generic type names
- Is it possible to disable swagger.json endpoint and generate a plain json?
- Release v0.21.0 with swagger webjar implementation HOT 2
- Simple or-path produces incorrect tags HOT 1
- Getting 405 Method Not Allowed from combined routes HOT 3
- Demo example doesn't work HOT 1
- Non-class Scala types break TypeBuilder
- Logger Options in RhoRoutes
- Publish scala 3 artifacts HOT 3
- Getting 405 Method Not Allowed from combined routes with authentication
- Assembly doesn't like CollectionConverters
- Http4s, Scala, and main dependencies update HOT 3
- Maintainers wanted HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rho.