mirror of https://github.com/docker/docs.git
Add ping endpoint
Ping endpoint added so clients can get the list of authentication challenges before making an initial request. Updated MainHandler to return JSON object instead of a string. Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
parent
ead0224526
commit
93dc0285bc
|
|
@ -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"))
|
||||
|
|
|
|||
Loading…
Reference in New Issue