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

Lua Handler File #95

Closed
tooolbox opened this issue Jun 1, 2022 · 2 comments
Closed

Lua Handler File #95

tooolbox opened this issue Jun 1, 2022 · 2 comments
Labels
feature request Enhancement or feature request

Comments

@tooolbox
Copy link
Collaborator

tooolbox commented Jun 1, 2022

I just ran into a scenario where I want a Lua handler, but I don't want to put it in the server conf.

For example, I have an app that lives at /crud/ and I want /crud/email/ to be a REST endpoint. It needs to respond to /crud/email/5 and so on. This is not currently feasible with the file-based approach, but I much prefer files because I can have multiple distinct webapps that don't rely upon the server config.

I'm wondering if it would be feasible to have something like handler.lua as a supported way of responding to requests. If the directory contains a handler.lua, all requests prefixed by the path to that directory will execute that Lua script to respond to the request. Essentially the same as index.lua but for /* instead of just /.

To restate, if you have /a/b/handler.lua then the requests /a/b/banana and /a/b/apple/3 would be handled by executing /a/b/handler.lua. Perhaps if you also have /a/b/c/handler.lua then /a/b/c/joe would execute that file instead of the more general /a/b/handler.lua.

Thought?

@xyproto
Copy link
Owner

xyproto commented Jun 2, 2022

I think this is an excellent idea!

I also like the file-based approach, and this seems to be a good compromise. 👍

@xyproto xyproto added the feature request Enhancement or feature request label Jun 8, 2022
giuliolunati added a commit to giuliolunati/algernon that referenced this issue Mar 17, 2023
handle.lua files work as index.lua,
but "cover" also subtree
until "shadowed" by another handle.lua
giuliolunati added a commit to giuliolunati/algernon that referenced this issue Mar 22, 2023
handler.lua files work as index.lua,
but "cover" also the subtree
until "shadowed" by an index.* file,
or by another handler.lua
xyproto pushed a commit that referenced this issue Apr 20, 2023
handler.lua files work as index.lua,
but "cover" also the subtree
until "shadowed" by an index.* file,
or by another handler.lua
@tooolbox
Copy link
Collaborator Author

tooolbox commented May 1, 2023

Wow, this was done in #130 that is awesome!

@tooolbox tooolbox closed this as completed May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Enhancement or feature request
Projects
None yet
Development

No branches or pull requests

2 participants