func init() { r := mux.NewRouter() baseURL := "/" + APIVersion r.HandleFunc(baseURL+"/info", handlerGetInfo).Methods("GET") r.HandleFunc(baseURL+"/containers/json", handlerGetContainers).Methods("GET") r.HandleFunc(baseURL+"/containers/{id}/logs", handleContainerLogs).Methods("GET") r.HandleFunc(baseURL+"/containers/{id}/kill", handleContainerKill).Methods("POST") r.HandleFunc(baseURL+"/images/create", handleImagePull).Methods("POST") testHTTPServer = httptest.NewServer(handlerAccessLog(r)) }
func createRouter(d *Daemon) *mux.Router { r := mux.NewRouter() m := map[string]map[string]HttpApiFunc{ "GET": { "/configuration": getConfiguration, "/connections": getConnections, "/connections/{id:.*}": getConnection, "/networks": getNetworks, "/networks/{id:.*}": getNetwork, }, "POST": { "/configuration": setConfiguration, "/connections": createConnection, "/networks": createNetwork, "/cluster/bind": clusterBind, "/cluster/join": clusterJoin, "/cluster/leave": clusterLeave, "/adapter": psAdapter, }, "DELETE": { "/connections/{id:.*}": deleteConnection, "/networks/{id:.*}": deleteNetwork, }, } for method, routes := range m { for route, fct := range routes { handler := appHandler{d, fct} r.Path(API_VERSION + route).Methods(method).Handler(handler) if route == "/adapter" { r.Path(route).Methods(method).Handler(handler) } } } return r }