From 86f155490468d5fb7bdcebdce0c9be22c20fd61a Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 12 Sep 2015 11:33:39 +0100 Subject: [PATCH] hugo --- Caddyfile | 3 --- hugo.go | 8 +++++++- 2 files changed, 7 insertions(+), 4 deletions(-) delete mode 100644 Caddyfile 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 }