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

Cannt add "default" http route. Static_file dir should a part of routes #172

Open
eugenepaniot opened this issue Oct 4, 2022 · 0 comments
Labels
feature A new functionality

Comments

@eugenepaniot
Copy link
Contributor

http/http/server.lua

Lines 717 to 720 in da78c01

local r = self:match(request.method, request.path)
if r == nil then
return static_file(self, request, format)
end

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:

  1. through httpd.routes ;
  2. if nothing found from 1., it takes it as "static" content, if found returns funct;
  3. and finnaly returns 404 -
    return { status = 404 }

I suggest "static" directory path should be registered/added to httpd.routes as well.

@kyukhin kyukhin added the feature A new functionality label Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new functionality
Projects
None yet
Development

No branches or pull requests

2 participants