github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/composed-auth/restapi/operations/get_items_responses.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/runtime" 12 13 "github.com/thetreep/go-swagger/examples/composed-auth/models" 14 ) 15 16 // GetItemsOKCode is the HTTP code returned for type GetItemsOK 17 const GetItemsOKCode int = 200 18 19 /* 20 GetItemsOK multiple items 21 22 swagger:response getItemsOK 23 */ 24 type GetItemsOK struct { 25 26 /* 27 In: Body 28 */ 29 Payload []models.Item `json:"body,omitempty"` 30 } 31 32 // NewGetItemsOK creates GetItemsOK with default headers values 33 func NewGetItemsOK() *GetItemsOK { 34 35 return &GetItemsOK{} 36 } 37 38 // WithPayload adds the payload to the get items o k response 39 func (o *GetItemsOK) WithPayload(payload []models.Item) *GetItemsOK { 40 o.Payload = payload 41 return o 42 } 43 44 // SetPayload sets the payload to the get items o k response 45 func (o *GetItemsOK) SetPayload(payload []models.Item) { 46 o.Payload = payload 47 } 48 49 // WriteResponse to the client 50 func (o *GetItemsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 51 52 rw.WriteHeader(200) 53 payload := o.Payload 54 if payload == nil { 55 // return empty array 56 payload = make([]models.Item, 0, 50) 57 } 58 59 if err := producer.Produce(rw, payload); err != nil { 60 panic(err) // let the recovery middleware deal with this 61 } 62 } 63 64 /* 65 GetItemsDefault other error response 66 67 swagger:response getItemsDefault 68 */ 69 type GetItemsDefault struct { 70 _statusCode int 71 72 /* 73 In: Body 74 */ 75 Payload *models.Error `json:"body,omitempty"` 76 } 77 78 // NewGetItemsDefault creates GetItemsDefault with default headers values 79 func NewGetItemsDefault(code int) *GetItemsDefault { 80 if code <= 0 { 81 code = 500 82 } 83 84 return &GetItemsDefault{ 85 _statusCode: code, 86 } 87 } 88 89 // WithStatusCode adds the status to the get items default response 90 func (o *GetItemsDefault) WithStatusCode(code int) *GetItemsDefault { 91 o._statusCode = code 92 return o 93 } 94 95 // SetStatusCode sets the status to the get items default response 96 func (o *GetItemsDefault) SetStatusCode(code int) { 97 o._statusCode = code 98 } 99 100 // WithPayload adds the payload to the get items default response 101 func (o *GetItemsDefault) WithPayload(payload *models.Error) *GetItemsDefault { 102 o.Payload = payload 103 return o 104 } 105 106 // SetPayload sets the payload to the get items default response 107 func (o *GetItemsDefault) SetPayload(payload *models.Error) { 108 o.Payload = payload 109 } 110 111 // WriteResponse to the client 112 func (o *GetItemsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 113 114 rw.WriteHeader(o._statusCode) 115 if o.Payload != nil { 116 payload := o.Payload 117 if err := producer.Produce(rw, payload); err != nil { 118 panic(err) // let the recovery middleware deal with this 119 } 120 } 121 }