Do the API versioning differently
I want the consts to contain the API version in them.
This commit is contained in:
parent
0109c2f8f1
commit
1cbf2e82b5
1 changed files with 8 additions and 8 deletions
|
@ -11,11 +11,12 @@ import (
|
||||||
|
|
||||||
// TODO proper doc comments!
|
// TODO proper doc comments!
|
||||||
|
|
||||||
const API_VERSION = 1
|
const ApiVersion = "1"
|
||||||
|
const PathPrefix = "/api/" + ApiVersion
|
||||||
|
|
||||||
const PathAuthToken = "/auth/full"
|
const PathAuthToken = PathPrefix + "/auth/full"
|
||||||
const PathRegister = "/signup"
|
const PathRegister = PathPrefix + "/signup"
|
||||||
const PathWallet = "/wallet"
|
const PathWallet = PathPrefix + "/wallet"
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
auth auth.AuthInterface
|
auth auth.AuthInterface
|
||||||
|
@ -152,10 +153,9 @@ func (s *Server) checkAuth(
|
||||||
// PUT = "...creates a new resource or replaces a representation of the target resource with the request payload."
|
// PUT = "...creates a new resource or replaces a representation of the target resource with the request payload."
|
||||||
|
|
||||||
func (s *Server) Serve() {
|
func (s *Server) Serve() {
|
||||||
PathPrefix := fmt.Sprintf("/api/%d", API_VERSION)
|
http.HandleFunc(PathAuthToken, s.getAuthToken)
|
||||||
http.HandleFunc(PathPrefix+PathAuthToken, s.getAuthToken)
|
http.HandleFunc(PathWallet, s.handleWallet)
|
||||||
http.HandleFunc(PathPrefix+PathWallet, s.handleWallet)
|
http.HandleFunc(PathRegister, s.register)
|
||||||
http.HandleFunc(PathPrefix+PathRegister, s.register)
|
|
||||||
|
|
||||||
fmt.Println("Serving at localhost:8090")
|
fmt.Println("Serving at localhost:8090")
|
||||||
http.ListenAndServe("localhost:8090", nil)
|
http.ListenAndServe("localhost:8090", nil)
|
||||||
|
|
Loading…
Reference in a new issue