func runRegistrationServer(l net.Listener) { r := mux.NewRouter() r.HandleFunc("/pods/{uuid}", logReq(handleRegisterPod)).Methods("PUT") r.HandleFunc("/pods/{uuid}", logReq(handleUnregisterPod)).Methods("DELETE") r.HandleFunc("/pods/{uuid}/{app:.*}", logReq(handleRegisterApp)).Methods("PUT") if err := http.Serve(l, r); err != nil { stderr("Error serving registration HTTP: %v", err) } close(exitCh) }
func runPublicServer(l net.Listener) { r := mux.NewRouter().Headers("Metadata-Flavor", "AppContainer"). PathPrefix("/{token}/acMetadata/v1").Subrouter() mr := r.Methods("GET").Subrouter() mr.HandleFunc("/pod/annotations/", logReq(podGet(handlePodAnnotations))) mr.HandleFunc("/pod/annotations/{name}", logReq(podGet(handlePodAnnotation))) mr.HandleFunc("/pod/manifest", logReq(podGet(handlePodManifest))) mr.HandleFunc("/pod/uuid", logReq(handlePodUUID)) mr.HandleFunc("/apps/{app:.*}/annotations/", logReq(appGet(handleAppAnnotations))) mr.HandleFunc("/apps/{app:.*}/annotations/{name}", logReq(appGet(handleAppAnnotation))) mr.HandleFunc("/apps/{app:.*}/image/manifest", logReq(appGet(handleImageManifest))) mr.HandleFunc("/apps/{app:.*}/image/id", logReq(appGet(handleAppID))) r.HandleFunc("/pod/hmac/sign", logReq(handlePodSign)).Methods("POST") r.HandleFunc("/pod/hmac/verify", logReq(handlePodVerify)).Methods("POST") if err := http.Serve(l, r); err != nil { stderr("Error serving pod HTTP: %v", err) } close(exitCh) }