github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/auto-configure/restapi/operations/todos/find_todos_responses.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/runtime" 12 13 "github.com/thetreep/go-swagger/examples/auto-configure/models" 14 ) 15 16 // FindTodosOKCode is the HTTP code returned for type FindTodosOK 17 const FindTodosOKCode int = 200 18 19 /* 20 FindTodosOK list the todo operations 21 22 swagger:response findTodosOK 23 */ 24 type FindTodosOK struct { 25 26 /* 27 In: Body 28 */ 29 Payload []*models.Item `json:"body,omitempty"` 30 } 31 32 // NewFindTodosOK creates FindTodosOK with default headers values 33 func NewFindTodosOK() *FindTodosOK { 34 35 return &FindTodosOK{} 36 } 37 38 // WithPayload adds the payload to the find todos o k response 39 func (o *FindTodosOK) WithPayload(payload []*models.Item) *FindTodosOK { 40 o.Payload = payload 41 return o 42 } 43 44 // SetPayload sets the payload to the find todos o k response 45 func (o *FindTodosOK) SetPayload(payload []*models.Item) { 46 o.Payload = payload 47 } 48 49 // WriteResponse to the client 50 func (o *FindTodosOK) 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 FindTodosDefault generic error response 66 67 swagger:response findTodosDefault 68 */ 69 type FindTodosDefault struct { 70 _statusCode int 71 72 /* 73 In: Body 74 */ 75 Payload *models.Error `json:"body,omitempty"` 76 } 77 78 // NewFindTodosDefault creates FindTodosDefault with default headers values 79 func NewFindTodosDefault(code int) *FindTodosDefault { 80 if code <= 0 { 81 code = 500 82 } 83 84 return &FindTodosDefault{ 85 _statusCode: code, 86 } 87 } 88 89 // WithStatusCode adds the status to the find todos default response 90 func (o *FindTodosDefault) WithStatusCode(code int) *FindTodosDefault { 91 o._statusCode = code 92 return o 93 } 94 95 // SetStatusCode sets the status to the find todos default response 96 func (o *FindTodosDefault) SetStatusCode(code int) { 97 o._statusCode = code 98 } 99 100 // WithPayload adds the payload to the find todos default response 101 func (o *FindTodosDefault) WithPayload(payload *models.Error) *FindTodosDefault { 102 o.Payload = payload 103 return o 104 } 105 106 // SetPayload sets the payload to the find todos default response 107 func (o *FindTodosDefault) SetPayload(payload *models.Error) { 108 o.Payload = payload 109 } 110 111 // WriteResponse to the client 112 func (o *FindTodosDefault) 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 }