Browse Source

Make code build

master
Georg Hopp 7 years ago
parent
commit
3305b4c932
Signed by: ghopp GPG Key ID: 4C5D226768784538
  1. 21
      main.go

21
main.go

@ -28,7 +28,7 @@ import (
"encoding/json"
"net/http"
"strings"
"os"
//"os"
"io"
)
@ -41,10 +41,10 @@ type version struct {
}
func (handler *ApiHandler) ServeHTTP(
response ResponseWriter,
request *Request,
response http.ResponseWriter,
request *http.Request,
) {
dirs := strings.split(request.URL.Path, "/")
dirs := strings.Split(request.URL.Path, "/")
switch dirs[0] {
case "version":
v, err := json.Marshal(
@ -55,21 +55,20 @@ func (handler *ApiHandler) ServeHTTP(
},
)
if err != nil {
http.Error(w, "Unable to encode version information", 500)
http.Error(response, "Unable to encode version information", 500)
return
}
io.WriteString(w, string(v[:]))
io.WriteString(response, string(v[:]))
default:
http.NotFound(w, req)
http.NotFound(response, request)
return
}
}
func router() {
http.HandleFunc(
"/api/0.0.1/",
http.StripPrefix("/api/0.0.1/", ApiHandler{}),
)
handler := ApiHandler{}
http.Handle("/api/0.0.1/", http.StripPrefix("/api/0.0.1/", &handler))
}
// vim: ts=4 sts=4 sw=4 noet tw=72:
Loading…
Cancel
Save