gohttpserver/httpserver/handlers.go
sneak a9887634ab
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
add simple json endpoint example
2020-10-05 06:15:32 -07:00

16 lines
271 B
Go

package httpserver
import (
"net/http"
"time"
)
func (s *server) handleNow() http.HandlerFunc {
type response struct {
Now time.Time `json:"now"`
}
return func(w http.ResponseWriter, r *http.Request) {
s.respondJSON(w, r, &response{Now: time.Now()}, 200)
}
}