github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/generated/restapi/operations/pet/find_pets_by_status_responses.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package pet
     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/generated/models"
    14  )
    15  
    16  // FindPetsByStatusOKCode is the HTTP code returned for type FindPetsByStatusOK
    17  const FindPetsByStatusOKCode int = 200
    18  
    19  /*
    20  FindPetsByStatusOK successful operation
    21  
    22  swagger:response findPetsByStatusOK
    23  */
    24  type FindPetsByStatusOK struct {
    25  
    26  	/*
    27  	  In: Body
    28  	*/
    29  	Payload []*models.Pet `json:"body,omitempty"`
    30  }
    31  
    32  // NewFindPetsByStatusOK creates FindPetsByStatusOK with default headers values
    33  func NewFindPetsByStatusOK() *FindPetsByStatusOK {
    34  
    35  	return &FindPetsByStatusOK{}
    36  }
    37  
    38  // WithPayload adds the payload to the find pets by status o k response
    39  func (o *FindPetsByStatusOK) WithPayload(payload []*models.Pet) *FindPetsByStatusOK {
    40  	o.Payload = payload
    41  	return o
    42  }
    43  
    44  // SetPayload sets the payload to the find pets by status o k response
    45  func (o *FindPetsByStatusOK) SetPayload(payload []*models.Pet) {
    46  	o.Payload = payload
    47  }
    48  
    49  // WriteResponse to the client
    50  func (o *FindPetsByStatusOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
    51  
    52  	rw.WriteHeader(200)
    53  	payload := o.Payload
    54  	if payload == nil {
    55  		// return empty array
    56  		payload = make([]*models.Pet, 0, 50)
    57  	}
    58  
    59  	if err := producer.Produce(rw, payload); err != nil {
    60  		panic(err) // let the recovery middleware deal with this
    61  	}
    62  }
    63  
    64  // FindPetsByStatusBadRequestCode is the HTTP code returned for type FindPetsByStatusBadRequest
    65  const FindPetsByStatusBadRequestCode int = 400
    66  
    67  /*
    68  FindPetsByStatusBadRequest Invalid status value
    69  
    70  swagger:response findPetsByStatusBadRequest
    71  */
    72  type FindPetsByStatusBadRequest struct {
    73  }
    74  
    75  // NewFindPetsByStatusBadRequest creates FindPetsByStatusBadRequest with default headers values
    76  func NewFindPetsByStatusBadRequest() *FindPetsByStatusBadRequest {
    77  
    78  	return &FindPetsByStatusBadRequest{}
    79  }
    80  
    81  // WriteResponse to the client
    82  func (o *FindPetsByStatusBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
    83  
    84  	rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
    85  
    86  	rw.WriteHeader(400)
    87  }