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