github.com/circl-dev/go-swagger@v0.31.0/examples/todo-list/restapi/operations/todos/find_responses.go (about)

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