go-swagger-tutorial/restapi/operations/clock_post.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"
)
// ClockPostHandlerFunc turns a function with the right signature into a clock post handler
type ClockPostHandlerFunc func(ClockPostParams) middleware.Responder
// Handle executing the request and returning a response
func (fn ClockPostHandlerFunc) Handle(params ClockPostParams) middleware.Responder {
return fn(params)
}
// ClockPostHandler interface for that can handle valid clock post params
type ClockPostHandler interface {
Handle(ClockPostParams) middleware.Responder
}
// NewClockPost creates a new http.Handler for the clock post operation
func NewClockPost(ctx *middleware.Context, handler ClockPostHandler) *ClockPost {
return &ClockPost{Context: ctx, Handler: handler}
}
/*ClockPost swagger:route POST /time clockPost
Returns time of day.
*/
type ClockPost struct {
Context *middleware.Context
Handler ClockPostHandler
}
func (o *ClockPost) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
r = rCtx
}
var Params = NewClockPostParams()
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)
}