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