leafo / lapis

A web framework for Lua and OpenResty written in MoonScript
http://leafo.net/lapis/
MIT License
3.14k stars 247 forks source link

version 1.11.0 route get/post bug? #760

Open AdilsonDev opened 1 year ago

AdilsonDev commented 1 year ago

Hello @leafo

I have a problem here when moving from version 1.10.0 to 1.11.0 this route is giving a 404 error, this did not happen before in other previous versions.

Whenever I use / before the file name (/api/foo), the error occurs.

Would it be a bug?

app:get('/api/foo', '/api/foo', function(req)
  return { render = true, layout = "api.layout" }
end)
leafo commented 1 year ago

I hadn't considered the use-case where a route name looks like a path with a leading /. Is there a reason why you chose this approach?

Route names are intended to be partial module paths (eg. api.foo), since there are many parts of lapis that use the route name to automatically load the corresponding module.

AdilsonDev commented 1 year ago

No reason in particular, I just thought the file path would be "views" .. "/api/foo" so I put it with "/" and when updating Lapis it broke some routes on the website, but I already fixed the routes to use without the "/".

Thank you for your reply.