mirror of
https://github.com/stefanprodan/podinfo.git
synced 2026-03-03 02:20:18 +00:00
24 lines
414 B
Go
24 lines
414 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gorilla/mux"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
func (s *Server) delayHandler(w http.ResponseWriter, r *http.Request) {
|
|
vars := mux.Vars(r)
|
|
|
|
delay, err := strconv.Atoi(vars["wait"])
|
|
if err != nil {
|
|
s.ErrorResponse(w, r, err.Error(), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
time.Sleep(time.Duration(delay) * time.Second)
|
|
|
|
s.JSONResponse(w, r, map[string]int{"delay": delay})
|
|
}
|