forked from security/hakurei
cmd/pkgserver: constant string in pattern
This resolves patterns at compile time. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -106,12 +106,14 @@ func (index *packageIndex) handleGet(w http.ResponseWriter, r *http.Request) {
|
||||
}{len(values), values})
|
||||
}
|
||||
|
||||
const ApiVersion = "v1"
|
||||
// apiVersion is the name of the current API revision, as part of the pattern.
|
||||
const apiVersion = "v1"
|
||||
|
||||
func apiRoutes(mux *http.ServeMux, index *packageIndex) {
|
||||
mux.HandleFunc(fmt.Sprintf("GET /api/%s/info", ApiVersion), handleInfo)
|
||||
mux.HandleFunc(fmt.Sprintf("GET /api/%s/get", ApiVersion), index.handleGet)
|
||||
mux.HandleFunc(fmt.Sprintf("GET /api/%s/status/", ApiVersion), index.handleStatus)
|
||||
// registerAPI registers API handler functions.
|
||||
func (index *packageIndex) registerAPI(mux *http.ServeMux) {
|
||||
mux.HandleFunc("GET /api/"+apiVersion+"/info", handleInfo)
|
||||
mux.HandleFunc("GET /api/"+apiVersion+"/get", index.handleGet)
|
||||
mux.HandleFunc("GET /api/"+apiVersion+"/status/", index.handleStatus)
|
||||
mux.HandleFunc("GET /status/", index.handleStatus)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user