This commit is contained in:
Henrique Dias
2015-09-12 20:02:26 +01:00
parent a3a4c8cb5e
commit eef006d629
4 changed files with 74 additions and 15 deletions

18
hugo.go
View File

@@ -2,12 +2,13 @@ package hugo
import (
"net/http"
"strings"
"github.com/spf13/hugo/commands"
"github.com/mholt/caddy/config/setup"
"github.com/mholt/caddy/middleware"
"github.com/hacdias/caddy-hugo/routing"
)
// Setup function
@@ -23,20 +24,7 @@ type handler struct{ Next middleware.Handler }
func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
if middleware.Path(r.URL.Path).Matches("/admin") {
if middleware.Path(r.URL.Path).Matches("/admin/new") {
w.Write([]byte("New"))
} else if middleware.Path(r.URL.Path).Matches("/admin/edit") {
var fileName string
fileName = strings.Replace(r.URL.Path, "/admin/edit", "", 1)
w.Write([]byte("Edit " + fileName))
} else {
w.Write([]byte("Admin"))
}
return 200, nil
return routing.Route(w, r)
}
return h.Next.ServeHTTP(w, r)