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

Feature request: invoke handler #211

Open
legobeat opened this issue Jul 3, 2024 · 2 comments
Open

Feature request: invoke handler #211

legobeat opened this issue Jul 3, 2024 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@legobeat
Copy link

legobeat commented Jul 3, 2024

It is often the case that we want to do some further handling of a request after termination with caddy-l4. One example would be using the caddy http module to match on HTTP headers, rewrite URLs, or conditionally forward to different downstreams.

We do have some existing overlap of functionality in the l4.http module but it doesn't seem desirable to start lifting over further "missing functionality" from caddy into l4, or as a user to fork it for this purpose.

Currently, I see two ways to achieve this without modifying caddy-l4:

  1. Putting caddy-l4 in listener_wrappers, wrapping downstream listeners
  2. Have a separate http app running on a local socket and have caddy-l4 dial it
    • This works fine and is relatively trivial to configure but is inefficient and ugly

If caddy-l4 adds support for an invoke handler matching the API of the http app and forwarding to named routes from other apps, it seems that we could get a nice middle-ground option which:

  • matches Caddy API
  • is relatively less complex than using listener_wrappers
  • shouldn't need accommodating for protocol particularities or larger changes in caddy-l4

Possibly at some point later I could take a stab at an early implementation if I could get a sanity-check on the above assumptions and suggested approach.


Related:

@mholt
Copy link
Owner

mholt commented Jul 4, 2024

Have a separate http app running on a local socket and have caddy-l4 dial it

  • This works fine and is relatively trivial to configure but is inefficient and ugly

A while ago I experimented with making a listener that can "pipe" data directly within the process, without the inefficiencies of re-dialing: caddyserver/caddy#5040

It seems like that would go a long way to fulfilling the feature request?

@legobeat
Copy link
Author

legobeat commented Jul 5, 2024

@mholt Oh yeah, that looks even better, if changes to Caddy itself is on the table!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants