I would like to embed Caddy for serving static files and additionally handle HTTP requests to generate pages directly in Go.
I’m wondering why there is no router plugin for Caddy that allows routing request paths to proper handlers implemented in Go (gorilla like mux).
It seems like the basic functionality but I don’t see it in the docs. Is it because nobody has contributed such plugin or is it assumed to be simple enough to write your own middleware?
Or I am missing something?
I’ve made a simple middleware that delegates all requests to an http.ServeMux (so gorilla would work). It lets me host entire go applications as a caddy middleware.
Nice work. I’m glad it works for you. I’ll be updating all of my plugins for 0.9 sometime this week and should get around to making that more usable.
Note that there is aretools for helping with some of the “modifications” to caddy source to add this.
I don’t think its a glaring omission, just something that wasn’t conceived of as caddy came around. Proxying go apps was the standard way to do it, until I realized you can just embed your go app.
Configuration handling is still a tricky issue, which I tried to solve with magic. It may or may not still be successful magic, we’ll see.