github.com/circl-dev/go-swagger@v0.31.0/examples/auto-configure/restapi/operations/todos/find_todos_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/auto-configure/models"
    14  )
    15  
    16  // FindTodosOKCode is the HTTP code returned for type FindTodosOK
    17  const FindTodosOKCode int = 200
    18  
    19  /*FindTodosOK list the todo operations
    20  
    21  swagger:response findTodosOK
    22  */
    23  type FindTodosOK struct {
    24  
    25  	/*
    26  	  In: Body
    27  	*/
    28  	Payload []*models.Item `json:"body,omitempty"`
    29  }
    30  
    31  // NewFindTodosOK creates FindTodosOK with default headers values
    32  func NewFindTodosOK() *FindTodosOK {
    33  
    34  	return &FindTodosOK{}
    35  }
    36  
    37  // WithPayload adds the payload to the find todos o k response
    38  func (o *FindTodosOK) WithPayload(payload []*models.Item) *FindTodosOK {
    39  	o.Payload = payload
    40  	return o
    41  }
    42  
    43  // SetPayload sets the payload to the find todos o k response
    44  func (o *FindTodosOK) SetPayload(payload []*models.Item) {
    45  	o.Payload = payload
    46  }
    47  
    48  // WriteResponse to the client
    49  func (o *FindTodosOK) 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  /*FindTodosDefault generic error response
    64  
    65  swagger:response findTodosDefault
    66  */
    67  type FindTodosDefault struct {
    68  	_statusCode int
    69  
    70  	/*
    71  	  In: Body
    72  	*/
    73  	Payload *models.Error `json:"body,omitempty"`
    74  }
    75  
    76  // NewFindTodosDefault creates FindTodosDefault with default headers values
    77  func NewFindTodosDefault(code int) *FindTodosDefault {
    78  	if code <= 0 {
    79  		code = 500
    80  	}
    81  
    82  	return &FindTodosDefault{
    83  		_statusCode: code,
    84  	}
    85  }
    86  
    87  // WithStatusCode adds the status to the find todos default response
    88  func (o *FindTodosDefault) WithStatusCode(code int) *FindTodosDefault {
    89  	o._statusCode = code
    90  	return o
    91  }
    92  
    93  // SetStatusCode sets the status to the find todos default response
    94  func (o *FindTodosDefault) SetStatusCode(code int) {
    95  	o._statusCode = code
    96  }
    97  
    98  // WithPayload adds the payload to the find todos default response
    99  func (o *FindTodosDefault) WithPayload(payload *models.Error) *FindTodosDefault {
   100  	o.Payload = payload
   101  	return o
   102  }
   103  
   104  // SetPayload sets the payload to the find todos default response
   105  func (o *FindTodosDefault) SetPayload(payload *models.Error) {
   106  	o.Payload = payload
   107  }
   108  
   109  // WriteResponse to the client
   110  func (o *FindTodosDefault) 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  }