github.com/emreu/go-swagger@v0.22.1/examples/task-tracker/restapi/operations/tasks/upload_task_file_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 // UploadTaskFileCreatedCode is the HTTP code returned for type UploadTaskFileCreated 17 const UploadTaskFileCreatedCode int = 201 18 19 /*UploadTaskFileCreated File added 20 21 swagger:response uploadTaskFileCreated 22 */ 23 type UploadTaskFileCreated struct { 24 } 25 26 // NewUploadTaskFileCreated creates UploadTaskFileCreated with default headers values 27 func NewUploadTaskFileCreated() *UploadTaskFileCreated { 28 29 return &UploadTaskFileCreated{} 30 } 31 32 // WriteResponse to the client 33 func (o *UploadTaskFileCreated) 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 /*UploadTaskFileDefault Error response 41 42 swagger:response uploadTaskFileDefault 43 */ 44 type UploadTaskFileDefault 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 // NewUploadTaskFileDefault creates UploadTaskFileDefault with default headers values 58 func NewUploadTaskFileDefault(code int) *UploadTaskFileDefault { 59 if code <= 0 { 60 code = 500 61 } 62 63 return &UploadTaskFileDefault{ 64 _statusCode: code, 65 } 66 } 67 68 // WithStatusCode adds the status to the upload task file default response 69 func (o *UploadTaskFileDefault) WithStatusCode(code int) *UploadTaskFileDefault { 70 o._statusCode = code 71 return o 72 } 73 74 // SetStatusCode sets the status to the upload task file default response 75 func (o *UploadTaskFileDefault) SetStatusCode(code int) { 76 o._statusCode = code 77 } 78 79 // WithXErrorCode adds the xErrorCode to the upload task file default response 80 func (o *UploadTaskFileDefault) WithXErrorCode(xErrorCode string) *UploadTaskFileDefault { 81 o.XErrorCode = xErrorCode 82 return o 83 } 84 85 // SetXErrorCode sets the xErrorCode to the upload task file default response 86 func (o *UploadTaskFileDefault) SetXErrorCode(xErrorCode string) { 87 o.XErrorCode = xErrorCode 88 } 89 90 // WithPayload adds the payload to the upload task file default response 91 func (o *UploadTaskFileDefault) WithPayload(payload *models.Error) *UploadTaskFileDefault { 92 o.Payload = payload 93 return o 94 } 95 96 // SetPayload sets the payload to the upload task file default response 97 func (o *UploadTaskFileDefault) SetPayload(payload *models.Error) { 98 o.Payload = payload 99 } 100 101 // WriteResponse to the client 102 func (o *UploadTaskFileDefault) 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 }