Template extensions: plugin or extensions?

1. Output of caddy version:

: caddy version
v2.5.2 h1:eCJdLyEyAGzuQTa5Mh3gETnYWDClo1LjtQm2q9RNZrs=

though will upgrade to 2.6.1 soon.

2. How I run Caddy:

caddy  run   --watch   --config $rootDir/app/caddyfile   --adapter caddyfile

a. System environment:

Mac today but will deploy to alpine linux.

b. Command:


c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane. -->

d. My complete Caddy config:

: cat app/caddyfile
	https_port 3001
	auto_https disable_redirects

auth0.local.net {
	handle / {
	  root * app/sim

	handle /.well-known/openid-configuration {
	  root * app/sim
          rewrite * /.well-known/openid-configuration

	handle /.well-known/jwks.json {
	  root * app/sim
          rewrite * /.well-known/jwks.json

	handle /authorize {
	  root * app/sim
	  rewrite * /authorize.html
          # Delete nonc

3. The problem I’m having:

I am building an OAuth Provider Simulator and need to generate custom output.

I have this:

<form id="auth0Callback" method="post" action="https://localhost:5001/authenticate/callback">
  <input type="hidden" name="code" value="{{ authorization_code }}"/>

And I want to generate an authorization code. I see the terms plugins, modules and extensions in the documentation and am unclear which to investigate. Just looking for a hint before I dig deeper.

4. Error messages and/or full log output:

No errors yet.

5. What I already tried:


6. Links to relevant resources:

There’s only one way to add more functionality in Caddy, and they can use different names depending on which angle you’re looking at it.

When you implement your own functionality, you’re writing a Go module, and you “plug” it into Caddy at built time with xcaddy (our build tool).

AFAIK we never use the term “extensions” in Caddy, but the doc/guide for writing your own custom modules is titled “Extending Caddy”, because that is what you’re doing when you write a module & plug it in, you’re extending the functionality provided by Caddy.

If you want to write a templates module, that was added in templates: Add custom template function registration by kroppt · Pull Request #4757 · caddyserver/caddy · GitHub. Basically you just need to provide a module with an ID in the http.handlers.templates.functions.* namespace and implement the templates.CustomFunctions interface, then you can call your module as a template function in your template documents.


This topic was automatically closed after 30 days. New replies are no longer allowed.