// 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"

	"github.com/go-openapi/runtime/middleware"
)

// ElapseHandlerFunc turns a function with the right signature into a elapse handler
type ElapseHandlerFunc func(ElapseParams) middleware.Responder

// Handle executing the request and returning a response
func (fn ElapseHandlerFunc) Handle(params ElapseParams) middleware.Responder {
	return fn(params)
}

// ElapseHandler interface for that can handle valid elapse params
type ElapseHandler interface {
	Handle(ElapseParams) middleware.Responder
}

// NewElapse creates a new http.Handler for the elapse operation
func NewElapse(ctx *middleware.Context, handler ElapseHandler) *Elapse {
	return &Elapse{Context: ctx, Handler: handler}
}

/*
	Elapse swagger:route GET /elapse/{length} elapse

# Count down the number of seconds

Count down the seconds remaining
*/
type Elapse struct {
	Context *middleware.Context
	Handler ElapseHandler
}

func (o *Elapse) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
	route, rCtx, _ := o.Context.RouteInfo(r)
	if rCtx != nil {
		*r = *rCtx
	}
	var Params = NewElapseParams()
	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)

}
