github.com/emreu/go-swagger@v0.22.1/examples/task-tracker/restapi/operations/tasks/get_task_comments_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 // GetTaskCommentsOKCode is the HTTP code returned for type GetTaskCommentsOK 17 const GetTaskCommentsOKCode int = 200 18 19 /*GetTaskCommentsOK The list of comments 20 21 swagger:response getTaskCommentsOK 22 */ 23 type GetTaskCommentsOK struct { 24 25 /* 26 In: Body 27 */ 28 Payload []*models.Comment `json:"body,omitempty"` 29 } 30 31 // NewGetTaskCommentsOK creates GetTaskCommentsOK with default headers values 32 func NewGetTaskCommentsOK() *GetTaskCommentsOK { 33 34 return &GetTaskCommentsOK{} 35 } 36 37 // WithPayload adds the payload to the get task comments o k response 38 func (o *GetTaskCommentsOK) WithPayload(payload []*models.Comment) *GetTaskCommentsOK { 39 o.Payload = payload 40 return o 41 } 42 43 // SetPayload sets the payload to the get task comments o k response 44 func (o *GetTaskCommentsOK) SetPayload(payload []*models.Comment) { 45 o.Payload = payload 46 } 47 48 // WriteResponse to the client 49 func (o *GetTaskCommentsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 50 51 rw.WriteHeader(200) 52 payload := o.Payload 53 if payload == nil { 54 // return empty array 55 payload = make([]*models.Comment, 0, 50) 56 } 57 58 if err := producer.Produce(rw, payload); err != nil { 59 panic(err) // let the recovery middleware deal with this 60 } 61 } 62 63 /*GetTaskCommentsDefault Error response 64 65 swagger:response getTaskCommentsDefault 66 */ 67 type GetTaskCommentsDefault struct { 68 _statusCode int 69 /* 70 71 */ 72 XErrorCode string `json:"X-Error-Code"` 73 74 /* 75 In: Body 76 */ 77 Payload *models.Error `json:"body,omitempty"` 78 } 79 80 // NewGetTaskCommentsDefault creates GetTaskCommentsDefault with default headers values 81 func NewGetTaskCommentsDefault(code int) *GetTaskCommentsDefault { 82 if code <= 0 { 83 code = 500 84 } 85 86 return &GetTaskCommentsDefault{ 87 _statusCode: code, 88 } 89 } 90 91 // WithStatusCode adds the status to the get task comments default response 92 func (o *GetTaskCommentsDefault) WithStatusCode(code int) *GetTaskCommentsDefault { 93 o._statusCode = code 94 return o 95 } 96 97 // SetStatusCode sets the status to the get task comments default response 98 func (o *GetTaskCommentsDefault) SetStatusCode(code int) { 99 o._statusCode = code 100 } 101 102 // WithXErrorCode adds the xErrorCode to the get task comments default response 103 func (o *GetTaskCommentsDefault) WithXErrorCode(xErrorCode string) *GetTaskCommentsDefault { 104 o.XErrorCode = xErrorCode 105 return o 106 } 107 108 // SetXErrorCode sets the xErrorCode to the get task comments default response 109 func (o *GetTaskCommentsDefault) SetXErrorCode(xErrorCode string) { 110 o.XErrorCode = xErrorCode 111 } 112 113 // WithPayload adds the payload to the get task comments default response 114 func (o *GetTaskCommentsDefault) WithPayload(payload *models.Error) *GetTaskCommentsDefault { 115 o.Payload = payload 116 return o 117 } 118 119 // SetPayload sets the payload to the get task comments default response 120 func (o *GetTaskCommentsDefault) SetPayload(payload *models.Error) { 121 o.Payload = payload 122 } 123 124 // WriteResponse to the client 125 func (o *GetTaskCommentsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 126 127 // response header X-Error-Code 128 129 xErrorCode := o.XErrorCode 130 if xErrorCode != "" { 131 rw.Header().Set("X-Error-Code", xErrorCode) 132 } 133 134 rw.WriteHeader(o._statusCode) 135 if o.Payload != nil { 136 payload := o.Payload 137 if err := producer.Produce(rw, payload); err != nil { 138 panic(err) // let the recovery middleware deal with this 139 } 140 } 141 }