github.com/circl-dev/go-swagger@v0.31.0/examples/todo-list-strict/restapi/operations/todos/destroy_one_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package todos
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"net/http"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/strfmt"
    13  	"github.com/circl-dev/runtime/middleware"
    14  )
    15  
    16  // NewDestroyOneParams creates a new DestroyOneParams object
    17  // no default values defined in spec.
    18  func NewDestroyOneParams() DestroyOneParams {
    19  
    20  	return DestroyOneParams{}
    21  }
    22  
    23  // DestroyOneParams contains all the bound params for the destroy one operation
    24  // typically these are obtained from a http.Request
    25  //
    26  // swagger:parameters destroyOne
    27  type DestroyOneParams struct {
    28  
    29  	// HTTP Request Object
    30  	HTTPRequest *http.Request `json:"-"`
    31  
    32  	/*
    33  	  Required: true
    34  	  In: path
    35  	*/
    36  	ID string
    37  }
    38  
    39  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    40  // for simple values it will use straight method calls.
    41  //
    42  // To ensure default values, the struct must have been initialized with NewDestroyOneParams() beforehand.
    43  func (o *DestroyOneParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    44  	var res []error
    45  
    46  	o.HTTPRequest = r
    47  
    48  	rID, rhkID, _ := route.Params.GetOK("id")
    49  	if err := o.bindID(rID, rhkID, route.Formats); err != nil {
    50  		res = append(res, err)
    51  	}
    52  
    53  	if len(res) > 0 {
    54  		return errors.CompositeValidationError(res...)
    55  	}
    56  	return nil
    57  }
    58  
    59  // bindID binds and validates parameter ID from path.
    60  func (o *DestroyOneParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
    61  	var raw string
    62  	if len(rawData) > 0 {
    63  		raw = rawData[len(rawData)-1]
    64  	}
    65  
    66  	// Required: true
    67  	// Parameter is provided by construction from the route
    68  
    69  	o.ID = raw
    70  
    71  	return nil
    72  }