github.com/djarvur/go-swagger@v0.18.0/examples/composed-auth/restapi/operations/get_items_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  	models "github.com/go-swagger/go-swagger/examples/composed-auth/models"
    14  )
    15  
    16  // GetItemsOKCode is the HTTP code returned for type GetItemsOK
    17  const GetItemsOKCode int = 200
    18  
    19  /*GetItemsOK multiple items
    20  
    21  swagger:response getItemsOK
    22  */
    23  type GetItemsOK struct {
    24  
    25  	/*
    26  	  In: Body
    27  	*/
    28  	Payload []models.Item `json:"body,omitempty"`
    29  }
    30  
    31  // NewGetItemsOK creates GetItemsOK with default headers values
    32  func NewGetItemsOK() *GetItemsOK {
    33  
    34  	return &GetItemsOK{}
    35  }
    36  
    37  // WithPayload adds the payload to the get items o k response
    38  func (o *GetItemsOK) WithPayload(payload []models.Item) *GetItemsOK {
    39  	o.Payload = payload
    40  	return o
    41  }
    42  
    43  // SetPayload sets the payload to the get items o k response
    44  func (o *GetItemsOK) SetPayload(payload []models.Item) {
    45  	o.Payload = payload
    46  }
    47  
    48  // WriteResponse to the client
    49  func (o *GetItemsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
    50  
    51  	rw.WriteHeader(200)
    52  	payload := o.Payload
    53  	if payload == nil {
    54  		payload = make([]models.Item, 0, 50)
    55  	}
    56  
    57  	if err := producer.Produce(rw, payload); err != nil {
    58  		panic(err) // let the recovery middleware deal with this
    59  	}
    60  
    61  }
    62  
    63  /*GetItemsDefault other error response
    64  
    65  swagger:response getItemsDefault
    66  */
    67  type GetItemsDefault struct {
    68  	_statusCode int
    69  
    70  	/*
    71  	  In: Body
    72  	*/
    73  	Payload *models.Error `json:"body,omitempty"`
    74  }
    75  
    76  // NewGetItemsDefault creates GetItemsDefault with default headers values
    77  func NewGetItemsDefault(code int) *GetItemsDefault {
    78  	if code <= 0 {
    79  		code = 500
    80  	}
    81  
    82  	return &GetItemsDefault{
    83  		_statusCode: code,
    84  	}
    85  }
    86  
    87  // WithStatusCode adds the status to the get items default response
    88  func (o *GetItemsDefault) WithStatusCode(code int) *GetItemsDefault {
    89  	o._statusCode = code
    90  	return o
    91  }
    92  
    93  // SetStatusCode sets the status to the get items default response
    94  func (o *GetItemsDefault) SetStatusCode(code int) {
    95  	o._statusCode = code
    96  }
    97  
    98  // WithPayload adds the payload to the get items default response
    99  func (o *GetItemsDefault) WithPayload(payload *models.Error) *GetItemsDefault {
   100  	o.Payload = payload
   101  	return o
   102  }
   103  
   104  // SetPayload sets the payload to the get items default response
   105  func (o *GetItemsDefault) SetPayload(payload *models.Error) {
   106  	o.Payload = payload
   107  }
   108  
   109  // WriteResponse to the client
   110  func (o *GetItemsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
   111  
   112  	rw.WriteHeader(o._statusCode)
   113  	if o.Payload != nil {
   114  		payload := o.Payload
   115  		if err := producer.Produce(rw, payload); err != nil {
   116  			panic(err) // let the recovery middleware deal with this
   117  		}
   118  	}
   119  }