diff --git a/Caddyfile b/Caddyfile deleted file mode 100644 index 79ef6899..00000000 --- a/Caddyfile +++ /dev/null @@ -1,3 +0,0 @@ -0.0.0.0 - -hugo diff --git a/hugo.go b/hugo.go index 91d391ee..8439950f 100644 --- a/hugo.go +++ b/hugo.go @@ -3,11 +3,17 @@ package hugo import ( "net/http" + "github.com/spf13/hugo/commands" + "github.com/mholt/caddy/config/setup" "github.com/mholt/caddy/middleware" ) func Setup(c *setup.Controller) (middleware.Middleware, error) { + for c.Next() { + commands.Execute() + } + return func(next middleware.Handler) middleware.Handler { return &handler{} }, nil @@ -16,6 +22,6 @@ func Setup(c *setup.Controller) (middleware.Middleware, error) { type handler struct{} func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - w.Write([]byte("Hello, I'm a caddy middleware")) + http.ServeFile(w, r, "public"+r.URL.Path) return 200, nil }