Files
podinfo/pkg/api/status.go
stefanprodan ba12154f68 Format imports
2020-03-24 13:03:51 +02:00

30 lines
600 B
Go

package api
import (
"net/http"
"strconv"
"github.com/gorilla/mux"
)
// Status godoc
// @Summary Status code
// @Description sets the response status code to the specified code
// @Tags HTTP API
// @Accept json
// @Produce json
// @Router /status/{code} [get]
// @Success 200 {object} api.MapResponse
func (s *Server) statusHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
code, err := strconv.Atoi(vars["code"])
if err != nil {
s.ErrorResponse(w, r, err.Error(), http.StatusBadRequest)
return
}
s.JSONResponseCode(w, r, map[string]int{"status": code}, code)
}