Small documentation inconsistency
metacatdud opened this issue · comments
Hi guys.
I was just testing oto and so far so good. I love it. It's simple and does with it suppose to do.
There is a small glitch in understanding on handle mapping that might put the brains of the week of heart in an infinite loop :)
Given the following code
srv := otohttp.NewServer()
RegisterHelloWorld(srv, helloWorldService)
http.Handle("/oto/", srv)
Works, but if I want to do this
srv := otohttp.NewServer()
RegisterHelloWorld(srv, helloWorldService)
http.Handle("/api/v2/", srv)
I get a 404. Took me a solid 30-45 mins until I decided to take a peek inside the lib to see the oto does a base map that defaults to /oto/
The only workaround I found but is ugly and redundant is to match patterns by overwriting the Basepath
srv := otohttp.NewServer()
srv.Basepath = "/api/v1/"
RegisterHelloWorld(srv, helloWorldService)
http.Handle("/api/v1/", srv)
Is there another way to do this?
That is the only way right now, sorry.
We use it to map to /api
or whatever is convenience. Yeah 404 is a bit annoying, but not sure how we could improve that, any suggestions are welcome
@metacatdud revisiting this, do you think we should ask people to explicitly set the base path in the NewServer
constructor?
Hey, either of these?
- Leave it as it is but make documentation clear that internally a prefix
/oto/
is set - Yes, allow devs to define in
NewServer
Frankly, I think is just a communication issue and can be addressed super easily by updating the documentation.
@metacatdud How's that?
I use the server.Basepath
in the http.Handle
to make it clear that they should be the same.
Yes. Much better. Now you have full control of what is going on. We can close this.
thanks @metacatdud