func()

in local-container-endpoints/handlers/credentials_handler.go [120:141]


func (service *CredentialService) getRoleHandler() func(w http.ResponseWriter, r *http.Request) error {
	return func(w http.ResponseWriter, r *http.Request) error {
		logrus.Debug("Received role credentials request")

		vars := mux.Vars(r)
		roleName := vars["role"]
		if roleName == "" {
			return HTTPError{
				Code: http.StatusBadRequest,
				Err:  fmt.Errorf("Invalid URL path %s; expected '/role/<IAM Role Name>'", r.URL.Path),
			}
		}

		response, err := service.getRoleCredentials(roleName)
		if err != nil {
			return err
		}

		writeJSONResponse(w, response)
		return nil
	}
}