github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/examples/task-tracker/restapi/operations/tasks/list_tasks.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package tasks 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the generate command 7 8 import ( 9 "net/http" 10 11 "github.com/go-openapi/runtime/middleware" 12 ) 13 14 // ListTasksHandlerFunc turns a function with the right signature into a list tasks handler 15 type ListTasksHandlerFunc func(ListTasksParams) middleware.Responder 16 17 // Handle executing the request and returning a response 18 func (fn ListTasksHandlerFunc) Handle(params ListTasksParams) middleware.Responder { 19 return fn(params) 20 } 21 22 // ListTasksHandler interface for that can handle valid list tasks params 23 type ListTasksHandler interface { 24 Handle(ListTasksParams) middleware.Responder 25 } 26 27 // NewListTasks creates a new http.Handler for the list tasks operation 28 func NewListTasks(ctx *middleware.Context, handler ListTasksHandler) *ListTasks { 29 return &ListTasks{Context: ctx, Handler: handler} 30 } 31 32 /* 33 ListTasks swagger:route GET /tasks tasks listTasks 34 35 # Lists the tasks 36 37 Allows for specifying a number of filter parameters to 38 narrow down the results. 39 Also allows for specifying a **sinceId** and **pageSize** parameter 40 to page through large result sets. 41 */ 42 type ListTasks struct { 43 Context *middleware.Context 44 Handler ListTasksHandler 45 } 46 47 func (o *ListTasks) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 48 route, rCtx, _ := o.Context.RouteInfo(r) 49 if rCtx != nil { 50 *r = *rCtx 51 } 52 var Params = NewListTasksParams() 53 if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 54 o.Context.Respond(rw, r, route.Produces, route, err) 55 return 56 } 57 58 res := o.Handler.Handle(Params) // actually handle the request 59 o.Context.Respond(rw, r, route.Produces, route, res) 60 61 }