Cleanup code

This changes variable names that were abbreviations, uses more constants
from the net/http package and improves the json decoding / encoding.
This commit is contained in:
Felix Auringer
2021-04-27 08:47:11 +02:00
parent 78668ad430
commit 712d0e6420
4 changed files with 17 additions and 14 deletions

View File

@ -1,8 +1,11 @@
package api
import "github.com/gorilla/mux"
import (
"github.com/gorilla/mux"
"net/http"
)
// NewRouter returns an HTTP handler (net.Handler) which can then
// NewRouter returns an HTTP handler (http.Handler) which can then
// be used by the net/http package to serve the api of our API.
// We use gorilla/mux because it is more convenient than net/http,
// e.g. when extracting path parameters.
@ -11,7 +14,7 @@ func NewRouter() *mux.Router {
// this can later be restricted to a specific host with
// `router.Host(...)` and to HTTPS with `router.Schemes("https")`
v1 := router.PathPrefix("/api/v1").Subrouter()
v1.HandleFunc("/health", Health).Methods("GET")
v1.HandleFunc("/health", Health).Methods(http.MethodGet)
return v1
}