github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/authentication/restapi/operations/customers/create_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package customers 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/authentication/models" 14 ) 15 16 // CreateCreatedCode is the HTTP code returned for type CreateCreated 17 const CreateCreatedCode int = 201 18 19 /* 20 CreateCreated created 21 22 swagger:response createCreated 23 */ 24 type CreateCreated struct { 25 26 /* 27 In: Body 28 */ 29 Payload *models.Customer `json:"body,omitempty"` 30 } 31 32 // NewCreateCreated creates CreateCreated with default headers values 33 func NewCreateCreated() *CreateCreated { 34 35 return &CreateCreated{} 36 } 37 38 // WithPayload adds the payload to the create created response 39 func (o *CreateCreated) WithPayload(payload *models.Customer) *CreateCreated { 40 o.Payload = payload 41 return o 42 } 43 44 // SetPayload sets the payload to the create created response 45 func (o *CreateCreated) SetPayload(payload *models.Customer) { 46 o.Payload = payload 47 } 48 49 // WriteResponse to the client 50 func (o *CreateCreated) 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 CreateDefault error 63 64 swagger:response createDefault 65 */ 66 type CreateDefault struct { 67 _statusCode int 68 69 /* 70 In: Body 71 */ 72 Payload *models.Error `json:"body,omitempty"` 73 } 74 75 // NewCreateDefault creates CreateDefault with default headers values 76 func NewCreateDefault(code int) *CreateDefault { 77 if code <= 0 { 78 code = 500 79 } 80 81 return &CreateDefault{ 82 _statusCode: code, 83 } 84 } 85 86 // WithStatusCode adds the status to the create default response 87 func (o *CreateDefault) WithStatusCode(code int) *CreateDefault { 88 o._statusCode = code 89 return o 90 } 91 92 // SetStatusCode sets the status to the create default response 93 func (o *CreateDefault) SetStatusCode(code int) { 94 o._statusCode = code 95 } 96 97 // WithPayload adds the payload to the create default response 98 func (o *CreateDefault) WithPayload(payload *models.Error) *CreateDefault { 99 o.Payload = payload 100 return o 101 } 102 103 // SetPayload sets the payload to the create default response 104 func (o *CreateDefault) SetPayload(payload *models.Error) { 105 o.Payload = payload 106 } 107 108 // WriteResponse to the client 109 func (o *CreateDefault) 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 }