func()

in local-container-endpoints/handlers/credentials_handler.go [144:166]


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

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

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

		writeJSONResponse(w, response)
		return nil
	}
}