Middleware builder?

(Jungle Boogie) #1

Hi All,

I first heard about Caddy in November 2015 - when young Matt Holt was even younger!

Way back then there was a thing called caddyext to build caddy + plugins/middleware.

I don’t see that anymore at https://github.com/caddyserver so how would I build caddy from source along with https://github.com/wmark/caddy.upload?

Thanks for any pointers!

(Matt Holt) #2

Hey, long time no see!

Just put an import in run.go:

    _ "github.com/user/plugin"

From: https://github.com/mholt/caddy/wiki/Extending-Caddy#2-plug-in-your-plugin

(Jungle Boogie) #3

Hey Matt,

So put that in run.go and do

go get -u github.com/mholt/caddy/caddy

That’s it?

(Matt Holt) #4

No, run go build. If you’re not in main.go’s directory, you can do: go build github.com/mholt/caddy/caddy. It plops a binary right there.

If you want proper version information (recommended), use ./build.bash.

(Jungle Boogie) #5

So I was able to have caddy.upload build successfully back in May. Since then, I don’t know what’s changed.

Here’s some context lines around caddymain/run.go:

 32     "github.com/mholt/caddy"                                                                                                                                                                                                                                                  
 33     // plug in the HTTP server type                                                                                                                                                                                                                                           
 34     _ "github.com/mholt/caddy/caddyhttp"                                                                                                                                                                                                                                      
 36     "github.com/mholt/caddy/caddytls"                                                                                                                                                                                                                                         
 37     // This is where other plugins get plugged in (imported)                                                                                                                                                                                                                  
 38     _ "blitznote.com/src/caddy.upload"                                                                                                                                                                                                                                        
 39 )  

Then I run go run build.go at ~/bin/gopath/src/github.com/mholt/caddy/caddy

% echo $GOPATH

Am I doing something wrong?

I’ve deleted caddy related files and subdirectories out from my gopath, along with the caddy.upload to have a fresh start. Then added the _ import line from above back in, but I have the same results:

% sudo caddy -conf /usr/local/www/Caddyfile 
Activating privacy features... done.
2017/11/12 14:15:02 no action found for directive 'upload' with server type 'http' (missing a plugin?)

I’m also referencing this page:

(Jungle Boogie) #6

Everything I said above is true and correct. Everything above also works correctly!

My problem was with the caddy I was actually ‘calling’ when starting.
What a silly mistake!

(Jim) #7

@jungle-boogie assuming this is a new HTTP plugin and new Caddyfile directive. Then you also need to add your new directive into caddy/caddyhttp/httpserver/plugin.go by adding it to var directives You could drop it in at the bottom of the list.