github.com/kaisawind/go-swagger@v0.19.0/examples/oauth2/restapi/operations/customers/create_responses.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package customers
     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/oauth2/models"
    14  )
    15  
    16  // CreateCreatedCode is the HTTP code returned for type CreateCreated
    17  const CreateCreatedCode int = 201
    18  
    19  /*CreateCreated created
    20  
    21  swagger:response createCreated
    22  */
    23  type CreateCreated struct {
    24  
    25  	/*
    26  	  In: Body
    27  	*/
    28  	Payload *models.Customer `json:"body,omitempty"`
    29  }
    30  
    31  // NewCreateCreated creates CreateCreated with default headers values
    32  func NewCreateCreated() *CreateCreated {
    33  
    34  	return &CreateCreated{}
    35  }
    36  
    37  // WithPayload adds the payload to the create created response
    38  func (o *CreateCreated) WithPayload(payload *models.Customer) *CreateCreated {
    39  	o.Payload = payload
    40  	return o
    41  }
    42  
    43  // SetPayload sets the payload to the create created response
    44  func (o *CreateCreated) SetPayload(payload *models.Customer) {
    45  	o.Payload = payload
    46  }
    47  
    48  // WriteResponse to the client
    49  func (o *CreateCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
    50  
    51  	rw.WriteHeader(201)
    52  	if o.Payload != nil {
    53  		payload := o.Payload
    54  		if err := producer.Produce(rw, payload); err != nil {
    55  			panic(err) // let the recovery middleware deal with this
    56  		}
    57  	}
    58  }
    59  
    60  /*CreateDefault error
    61  
    62  swagger:response createDefault
    63  */
    64  type CreateDefault struct {
    65  	_statusCode int
    66  
    67  	/*
    68  	  In: Body
    69  	*/
    70  	Payload *models.Error `json:"body,omitempty"`
    71  }
    72  
    73  // NewCreateDefault creates CreateDefault with default headers values
    74  func NewCreateDefault(code int) *CreateDefault {
    75  	if code <= 0 {
    76  		code = 500
    77  	}
    78  
    79  	return &CreateDefault{
    80  		_statusCode: code,
    81  	}
    82  }
    83  
    84  // WithStatusCode adds the status to the create default response
    85  func (o *CreateDefault) WithStatusCode(code int) *CreateDefault {
    86  	o._statusCode = code
    87  	return o
    88  }
    89  
    90  // SetStatusCode sets the status to the create default response
    91  func (o *CreateDefault) SetStatusCode(code int) {
    92  	o._statusCode = code
    93  }
    94  
    95  // WithPayload adds the payload to the create default response
    96  func (o *CreateDefault) WithPayload(payload *models.Error) *CreateDefault {
    97  	o.Payload = payload
    98  	return o
    99  }
   100  
   101  // SetPayload sets the payload to the create default response
   102  func (o *CreateDefault) SetPayload(payload *models.Error) {
   103  	o.Payload = payload
   104  }
   105  
   106  // WriteResponse to the client
   107  func (o *CreateDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
   108  
   109  	rw.WriteHeader(o._statusCode)
   110  	if o.Payload != nil {
   111  		payload := o.Payload
   112  		if err := producer.Produce(rw, payload); err != nil {
   113  			panic(err) // let the recovery middleware deal with this
   114  		}
   115  	}
   116  }