github.com/emreu/go-swagger@v0.22.1/examples/task-tracker/restapi/operations/tasks/create_task_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package tasks 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 models "github.com/go-swagger/go-swagger/examples/task-tracker/models" 14 ) 15 16 // CreateTaskCreatedCode is the HTTP code returned for type CreateTaskCreated 17 const CreateTaskCreatedCode int = 201 18 19 /*CreateTaskCreated Task created 20 21 swagger:response createTaskCreated 22 */ 23 type CreateTaskCreated struct { 24 } 25 26 // NewCreateTaskCreated creates CreateTaskCreated with default headers values 27 func NewCreateTaskCreated() *CreateTaskCreated { 28 29 return &CreateTaskCreated{} 30 } 31 32 // WriteResponse to the client 33 func (o *CreateTaskCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 34 35 rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 36 37 rw.WriteHeader(201) 38 } 39 40 /*CreateTaskDefault Error response 41 42 swagger:response createTaskDefault 43 */ 44 type CreateTaskDefault struct { 45 _statusCode int 46 /* 47 48 */ 49 XErrorCode string `json:"X-Error-Code"` 50 51 /* 52 In: Body 53 */ 54 Payload *models.Error `json:"body,omitempty"` 55 } 56 57 // NewCreateTaskDefault creates CreateTaskDefault with default headers values 58 func NewCreateTaskDefault(code int) *CreateTaskDefault { 59 if code <= 0 { 60 code = 500 61 } 62 63 return &CreateTaskDefault{ 64 _statusCode: code, 65 } 66 } 67 68 // WithStatusCode adds the status to the create task default response 69 func (o *CreateTaskDefault) WithStatusCode(code int) *CreateTaskDefault { 70 o._statusCode = code 71 return o 72 } 73 74 // SetStatusCode sets the status to the create task default response 75 func (o *CreateTaskDefault) SetStatusCode(code int) { 76 o._statusCode = code 77 } 78 79 // WithXErrorCode adds the xErrorCode to the create task default response 80 func (o *CreateTaskDefault) WithXErrorCode(xErrorCode string) *CreateTaskDefault { 81 o.XErrorCode = xErrorCode 82 return o 83 } 84 85 // SetXErrorCode sets the xErrorCode to the create task default response 86 func (o *CreateTaskDefault) SetXErrorCode(xErrorCode string) { 87 o.XErrorCode = xErrorCode 88 } 89 90 // WithPayload adds the payload to the create task default response 91 func (o *CreateTaskDefault) WithPayload(payload *models.Error) *CreateTaskDefault { 92 o.Payload = payload 93 return o 94 } 95 96 // SetPayload sets the payload to the create task default response 97 func (o *CreateTaskDefault) SetPayload(payload *models.Error) { 98 o.Payload = payload 99 } 100 101 // WriteResponse to the client 102 func (o *CreateTaskDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 103 104 // response header X-Error-Code 105 106 xErrorCode := o.XErrorCode 107 if xErrorCode != "" { 108 rw.Header().Set("X-Error-Code", xErrorCode) 109 } 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 }