github.com/dirkm/go-swagger@v0.19.0/examples/composed-auth/restapi/operations/get_order_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package operations
     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/runtime/middleware"
    13  
    14  	strfmt "github.com/go-openapi/strfmt"
    15  )
    16  
    17  // NewGetOrderParams creates a new GetOrderParams object
    18  // no default values defined in spec.
    19  func NewGetOrderParams() GetOrderParams {
    20  
    21  	return GetOrderParams{}
    22  }
    23  
    24  // GetOrderParams contains all the bound params for the get order operation
    25  // typically these are obtained from a http.Request
    26  //
    27  // swagger:parameters GetOrder
    28  type GetOrderParams struct {
    29  
    30  	// HTTP Request Object
    31  	HTTPRequest *http.Request `json:"-"`
    32  
    33  	/*
    34  	  Required: true
    35  	  In: path
    36  	*/
    37  	OrderID string
    38  }
    39  
    40  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    41  // for simple values it will use straight method calls.
    42  //
    43  // To ensure default values, the struct must have been initialized with NewGetOrderParams() beforehand.
    44  func (o *GetOrderParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    45  	var res []error
    46  
    47  	o.HTTPRequest = r
    48  
    49  	rOrderID, rhkOrderID, _ := route.Params.GetOK("orderID")
    50  	if err := o.bindOrderID(rOrderID, rhkOrderID, route.Formats); err != nil {
    51  		res = append(res, err)
    52  	}
    53  
    54  	if len(res) > 0 {
    55  		return errors.CompositeValidationError(res...)
    56  	}
    57  	return nil
    58  }
    59  
    60  // bindOrderID binds and validates parameter OrderID from path.
    61  func (o *GetOrderParams) bindOrderID(rawData []string, hasKey bool, formats strfmt.Registry) error {
    62  	var raw string
    63  	if len(rawData) > 0 {
    64  		raw = rawData[len(rawData)-1]
    65  	}
    66  
    67  	// Required: true
    68  	// Parameter is provided by construction from the route
    69  
    70  	o.OrderID = raw
    71  
    72  	return nil
    73  }