go-swagger-tutorial/restapi/operations/clock_get.go

59 lines
1.5 KiB
Go

// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
middleware "github.com/go-openapi/runtime/middleware"
)
// ClockGetHandlerFunc turns a function with the right signature into a clock get handler
type ClockGetHandlerFunc func(ClockGetParams) middleware.Responder
// Handle executing the request and returning a response
func (fn ClockGetHandlerFunc) Handle(params ClockGetParams) middleware.Responder {
return fn(params)
}
// ClockGetHandler interface for that can handle valid clock get params
type ClockGetHandler interface {
Handle(ClockGetParams) middleware.Responder
}
// NewClockGet creates a new http.Handler for the clock get operation
func NewClockGet(ctx *middleware.Context, handler ClockGetHandler) *ClockGet {
return &ClockGet{Context: ctx, Handler: handler}
}
/*ClockGet swagger:route GET /time clockGet
Returns time of day.
*/
type ClockGet struct {
Context *middleware.Context
Handler ClockGetHandler
}
func (o *ClockGet) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
r = rCtx
}
var Params = NewClockGetParams()
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}