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