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