Cannt add "default" http route. Static_file dir should a part of routes
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 81
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/tarantool/http/blob/da78c018a620f88b930f5f1aa0f14fbc39745ccc/http/server.lua#L717-L720
Static_file dir should a part of route.
httpd:route(
{path = "/*slug", public = true, name = "default"},
http_middleware.v1(handle_get_default, http_collector)
)
Currently it is not possible to have "default" http endpoint and static content path at the same time. As "default" overlap "static_file".
I'd like to have default http route to match "unspecified" routes, to log it and return specific/custom response (json, etc.). Currently it is not possible because it iterates/bruteforces:
- through
httpd.routes; - if nothing found from 1., it takes it as "static" content, if found returns funct;
- and finnaly returns 404 - https://github.com/tarantool/http/blob/da78c018a620f88b930f5f1aa0f14fbc39745ccc/http/server.lua#L611
I suggest "static" directory path should be registered/added to httpd.routes as well.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in http/server.lua at the route handling around lines 611 and 717-720, and trace how httpd.routes is checked before static content is served. Compare the requested default route behavior with the existing static-file fallback; done means an unspecified route can be logged and given a custom response while static content remains available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100