github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/generated/restapi/operations/user/get_user_by_name_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package user 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 "github.com/go-openapi/strfmt" 14 ) 15 16 // NewGetUserByNameParams creates a new GetUserByNameParams object 17 // 18 // There are no default values defined in the spec. 19 func NewGetUserByNameParams() GetUserByNameParams { 20 21 return GetUserByNameParams{} 22 } 23 24 // GetUserByNameParams contains all the bound params for the get user by name operation 25 // typically these are obtained from a http.Request 26 // 27 // swagger:parameters getUserByName 28 type GetUserByNameParams struct { 29 30 // HTTP Request Object 31 HTTPRequest *http.Request `json:"-"` 32 33 /*The name that needs to be fetched. Use user1 for testing. 34 Required: true 35 In: path 36 */ 37 Username 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 NewGetUserByNameParams() beforehand. 44 func (o *GetUserByNameParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 var res []error 46 47 o.HTTPRequest = r 48 49 rUsername, rhkUsername, _ := route.Params.GetOK("username") 50 if err := o.bindUsername(rUsername, rhkUsername, route.Formats); err != nil { 51 res = append(res, err) 52 } 53 if len(res) > 0 { 54 return errors.CompositeValidationError(res...) 55 } 56 return nil 57 } 58 59 // bindUsername binds and validates parameter Username from path. 60 func (o *GetUserByNameParams) bindUsername(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 o.Username = raw 69 70 return nil 71 }