github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/examples/composed-auth/restapi/operations/add_order_responses.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package operations
     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/composed-auth/models"
    14  )
    15  
    16  // AddOrderOKCode is the HTTP code returned for type AddOrderOK
    17  const AddOrderOKCode int = 200
    18  
    19  /*
    20  AddOrderOK empty response
    21  
    22  swagger:response addOrderOK
    23  */
    24  type AddOrderOK struct {
    25  }
    26  
    27  // NewAddOrderOK creates AddOrderOK with default headers values
    28  func NewAddOrderOK() *AddOrderOK {
    29  
    30  	return &AddOrderOK{}
    31  }
    32  
    33  // WriteResponse to the client
    34  func (o *AddOrderOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
    35  
    36  	rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
    37  
    38  	rw.WriteHeader(200)
    39  }
    40  
    41  // AddOrderUnauthorizedCode is the HTTP code returned for type AddOrderUnauthorized
    42  const AddOrderUnauthorizedCode int = 401
    43  
    44  /*
    45  AddOrderUnauthorized unauthorized access for a lack of authentication
    46  
    47  swagger:response addOrderUnauthorized
    48  */
    49  type AddOrderUnauthorized struct {
    50  }
    51  
    52  // NewAddOrderUnauthorized creates AddOrderUnauthorized with default headers values
    53  func NewAddOrderUnauthorized() *AddOrderUnauthorized {
    54  
    55  	return &AddOrderUnauthorized{}
    56  }
    57  
    58  // WriteResponse to the client
    59  func (o *AddOrderUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
    60  
    61  	rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
    62  
    63  	rw.WriteHeader(401)
    64  }
    65  
    66  // AddOrderForbiddenCode is the HTTP code returned for type AddOrderForbidden
    67  const AddOrderForbiddenCode int = 403
    68  
    69  /*
    70  AddOrderForbidden forbidden access for a lack of sufficient privileges
    71  
    72  swagger:response addOrderForbidden
    73  */
    74  type AddOrderForbidden struct {
    75  }
    76  
    77  // NewAddOrderForbidden creates AddOrderForbidden with default headers values
    78  func NewAddOrderForbidden() *AddOrderForbidden {
    79  
    80  	return &AddOrderForbidden{}
    81  }
    82  
    83  // WriteResponse to the client
    84  func (o *AddOrderForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
    85  
    86  	rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
    87  
    88  	rw.WriteHeader(403)
    89  }
    90  
    91  /*
    92  AddOrderDefault other error response
    93  
    94  swagger:response addOrderDefault
    95  */
    96  type AddOrderDefault struct {
    97  	_statusCode int
    98  
    99  	/*
   100  	  In: Body
   101  	*/
   102  	Payload *models.Error `json:"body,omitempty"`
   103  }
   104  
   105  // NewAddOrderDefault creates AddOrderDefault with default headers values
   106  func NewAddOrderDefault(code int) *AddOrderDefault {
   107  	if code <= 0 {
   108  		code = 500
   109  	}
   110  
   111  	return &AddOrderDefault{
   112  		_statusCode: code,
   113  	}
   114  }
   115  
   116  // WithStatusCode adds the status to the add order default response
   117  func (o *AddOrderDefault) WithStatusCode(code int) *AddOrderDefault {
   118  	o._statusCode = code
   119  	return o
   120  }
   121  
   122  // SetStatusCode sets the status to the add order default response
   123  func (o *AddOrderDefault) SetStatusCode(code int) {
   124  	o._statusCode = code
   125  }
   126  
   127  // WithPayload adds the payload to the add order default response
   128  func (o *AddOrderDefault) WithPayload(payload *models.Error) *AddOrderDefault {
   129  	o.Payload = payload
   130  	return o
   131  }
   132  
   133  // SetPayload sets the payload to the add order default response
   134  func (o *AddOrderDefault) SetPayload(payload *models.Error) {
   135  	o.Payload = payload
   136  }
   137  
   138  // WriteResponse to the client
   139  func (o *AddOrderDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
   140  
   141  	rw.WriteHeader(o._statusCode)
   142  	if o.Payload != nil {
   143  		payload := o.Payload
   144  		if err := producer.Produce(rw, payload); err != nil {
   145  			panic(err) // let the recovery middleware deal with this
   146  		}
   147  	}
   148  }