remove dangerous global variables

This commit is contained in:
Henrique Dias
2016-06-16 17:01:41 +01:00
parent 48878cc3b5
commit af2785e510
11 changed files with 66 additions and 82 deletions

View File

@@ -1,24 +1,16 @@
package git
import (
"errors"
"net/http"
"github.com/hacdias/caddy-hugo/config"
)
var (
conf *config.Config
)
// ServeHTTP is used to serve the content of GIT API.
func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
conf = c
switch r.Method {
case "POST":
return POST(w, r)
default:
return http.StatusMethodNotAllowed, errors.New("Invalid method.")
if r.Method != http.MethodPost {
return http.StatusNotImplemented, nil
}
return POST(w, r, c)
}