mirror of
https://github.com/docker/docs.git
synced 2026-03-31 16:28:59 +07:00
Merge pull request #51 from dmcgowan/add-ping-endpoint
Add ping endpoint
This commit is contained in:
@@ -23,9 +23,13 @@ import (
|
||||
// MainHandler is the default handler for the server
|
||||
func MainHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) *errors.HTTPError {
|
||||
if r.Method == "GET" {
|
||||
err := json.NewEncoder(w).Encode("{}")
|
||||
_, err := w.Write([]byte("{}"))
|
||||
if err != nil {
|
||||
w.Write([]byte("{server_error: 'Could not parse error message'}"))
|
||||
return &errors.HTTPError{
|
||||
HTTPStatus: http.StatusInternalServerError,
|
||||
Code: 9999,
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//w.WriteHeader(http.StatusNotFound)
|
||||
|
||||
@@ -76,6 +76,7 @@ func Run(ctx context.Context, addr, tlsCertFile, tlsKeyFile string, trust signed
|
||||
|
||||
r := mux.NewRouter()
|
||||
// TODO (endophage): use correct regexes for image and tag names
|
||||
r.Methods("GET").Path("/v2/").Handler(hand(handlers.MainHandler))
|
||||
r.Methods("POST").Path("/v2/{imageName:.*}/_trust/tuf/").Handler(hand(handlers.AtomicUpdateHandler, "push", "pull"))
|
||||
r.Methods("GET").Path("/v2/{imageName:.*}/_trust/tuf/{tufRole:(root|targets|snapshot)}.json").Handler(hand(handlers.GetHandler, "pull"))
|
||||
r.Methods("GET").Path("/v2/{imageName:.*}/_trust/tuf/timestamp.json").Handler(hand(handlers.GetTimestampHandler, "pull"))
|
||||
|
||||
Reference in New Issue
Block a user