github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/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  	"github.com/thetreep/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  /*
    20  AddCommentToTaskCreated Comment added
    21  
    22  swagger:response addCommentToTaskCreated
    23  */
    24  type AddCommentToTaskCreated struct {
    25  }
    26  
    27  // NewAddCommentToTaskCreated creates AddCommentToTaskCreated with default headers values
    28  func NewAddCommentToTaskCreated() *AddCommentToTaskCreated {
    29  
    30  	return &AddCommentToTaskCreated{}
    31  }
    32  
    33  // WriteResponse to the client
    34  func (o *AddCommentToTaskCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
    35  
    36  	rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
    37  
    38  	rw.WriteHeader(201)
    39  }
    40  
    41  /*
    42  AddCommentToTaskDefault Error response
    43  
    44  swagger:response addCommentToTaskDefault
    45  */
    46  type AddCommentToTaskDefault struct {
    47  	_statusCode int
    48  	/*
    49  
    50  	 */
    51  	XErrorCode string `json:"X-Error-Code"`
    52  
    53  	/*
    54  	  In: Body
    55  	*/
    56  	Payload *models.Error `json:"body,omitempty"`
    57  }
    58  
    59  // NewAddCommentToTaskDefault creates AddCommentToTaskDefault with default headers values
    60  func NewAddCommentToTaskDefault(code int) *AddCommentToTaskDefault {
    61  	if code <= 0 {
    62  		code = 500
    63  	}
    64  
    65  	return &AddCommentToTaskDefault{
    66  		_statusCode: code,
    67  	}
    68  }
    69  
    70  // WithStatusCode adds the status to the add comment to task default response
    71  func (o *AddCommentToTaskDefault) WithStatusCode(code int) *AddCommentToTaskDefault {
    72  	o._statusCode = code
    73  	return o
    74  }
    75  
    76  // SetStatusCode sets the status to the add comment to task default response
    77  func (o *AddCommentToTaskDefault) SetStatusCode(code int) {
    78  	o._statusCode = code
    79  }
    80  
    81  // WithXErrorCode adds the xErrorCode to the add comment to task default response
    82  func (o *AddCommentToTaskDefault) WithXErrorCode(xErrorCode string) *AddCommentToTaskDefault {
    83  	o.XErrorCode = xErrorCode
    84  	return o
    85  }
    86  
    87  // SetXErrorCode sets the xErrorCode to the add comment to task default response
    88  func (o *AddCommentToTaskDefault) SetXErrorCode(xErrorCode string) {
    89  	o.XErrorCode = xErrorCode
    90  }
    91  
    92  // WithPayload adds the payload to the add comment to task default response
    93  func (o *AddCommentToTaskDefault) WithPayload(payload *models.Error) *AddCommentToTaskDefault {
    94  	o.Payload = payload
    95  	return o
    96  }
    97  
    98  // SetPayload sets the payload to the add comment to task default response
    99  func (o *AddCommentToTaskDefault) SetPayload(payload *models.Error) {
   100  	o.Payload = payload
   101  }
   102  
   103  // WriteResponse to the client
   104  func (o *AddCommentToTaskDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
   105  
   106  	// response header X-Error-Code
   107  
   108  	xErrorCode := o.XErrorCode
   109  	if xErrorCode != "" {
   110  		rw.Header().Set("X-Error-Code", xErrorCode)
   111  	}
   112  
   113  	rw.WriteHeader(o._statusCode)
   114  	if o.Payload != nil {
   115  		payload := o.Payload
   116  		if err := producer.Produce(rw, payload); err != nil {
   117  			panic(err) // let the recovery middleware deal with this
   118  		}
   119  	}
   120  }