github.com/emreu/go-swagger@v0.22.1/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  	middleware "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  /*ListTasks swagger:route GET /tasks tasks listTasks
    33  
    34  Lists the tasks
    35  
    36  Allows for specifying a number of filter parameters to
    37  narrow down the results.
    38  Also allows for specifying a **sinceId** and **pageSize** parameter
    39  to page through large result sets.
    40  
    41  
    42  */
    43  type ListTasks struct {
    44  	Context *middleware.Context
    45  	Handler ListTasksHandler
    46  }
    47  
    48  func (o *ListTasks) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
    49  	route, rCtx, _ := o.Context.RouteInfo(r)
    50  	if rCtx != nil {
    51  		r = rCtx
    52  	}
    53  	var Params = NewListTasksParams()
    54  
    55  	if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
    56  		o.Context.Respond(rw, r, route.Produces, route, err)
    57  		return
    58  	}
    59  
    60  	res := o.Handler.Handle(Params) // actually handle the request
    61  
    62  	o.Context.Respond(rw, r, route.Produces, route, res)
    63  
    64  }