3 ms·
Yes, that would be useful. Basically, what you have in https://github.com/infogulch/caddy-xtemplate/blob/master/templates.go https://github.com/infogulch/caddy-
by lonk11 3y ago
Yes, that would be useful. Basically, what you have in https://github.com/infogulch/caddy-xtemplate/blob/master/templates.go https://github.com/infogulch/caddy-xtemplate/blob/master/tem... - but without Caddy dependencies and with a way to use any router library (I use gorilla/mux).
I would make the templates library take a callback function for every public template: func(method, path string, template).
Then the user could add any custom logic to register the route handler and execute the template with any application specific inputs.
- infogulch 3y agoI'll have to think about that. It currently uses path parameters from the julienschmidt/httprouter router implementation, which I think are pretty important. How would you expect to define and receive path parameters?
- lonk11 3y agogorilla/mux supports parameters in the path as well. For example: "/posts/{id:[0-9]+}" Passing the parameters from the handler to the template could be left to the user of the library.