github.com/emreu/go-swagger@v0.22.1/examples/todo-list/client/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 "fmt" 10 "io" 11 12 "github.com/go-openapi/runtime" 13 14 strfmt "github.com/go-openapi/strfmt" 15 16 models "github.com/go-swagger/go-swagger/examples/todo-list/models" 17 ) 18 19 // FindReader is a Reader for the Find structure. 20 type FindReader struct { 21 formats strfmt.Registry 22 } 23 24 // ReadResponse reads a server response into the received o. 25 func (o *FindReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 26 switch response.Code() { 27 case 200: 28 result := NewFindOK() 29 if err := result.readResponse(response, consumer, o.formats); err != nil { 30 return nil, err 31 } 32 return result, nil 33 default: 34 result := NewFindDefault(response.Code()) 35 if err := result.readResponse(response, consumer, o.formats); err != nil { 36 return nil, err 37 } 38 if response.Code()/100 == 2 { 39 return result, nil 40 } 41 return nil, result 42 } 43 } 44 45 // NewFindOK creates a FindOK with default headers values 46 func NewFindOK() *FindOK { 47 return &FindOK{} 48 } 49 50 /*FindOK handles this case with default header values. 51 52 OK 53 */ 54 type FindOK struct { 55 Payload []*models.Item 56 } 57 58 func (o *FindOK) Error() string { 59 return fmt.Sprintf("[GET /][%d] findOK %+v", 200, o.Payload) 60 } 61 62 func (o *FindOK) GetPayload() []*models.Item { 63 return o.Payload 64 } 65 66 func (o *FindOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 67 68 // response payload 69 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { 70 return err 71 } 72 73 return nil 74 } 75 76 // NewFindDefault creates a FindDefault with default headers values 77 func NewFindDefault(code int) *FindDefault { 78 return &FindDefault{ 79 _statusCode: code, 80 } 81 } 82 83 /*FindDefault handles this case with default header values. 84 85 error 86 */ 87 type FindDefault struct { 88 _statusCode int 89 90 Payload *models.Error 91 } 92 93 // Code gets the status code for the find default response 94 func (o *FindDefault) Code() int { 95 return o._statusCode 96 } 97 98 func (o *FindDefault) Error() string { 99 return fmt.Sprintf("[GET /][%d] find default %+v", o._statusCode, o.Payload) 100 } 101 102 func (o *FindDefault) GetPayload() *models.Error { 103 return o.Payload 104 } 105 106 func (o *FindDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 107 108 o.Payload = new(models.Error) 109 110 // response payload 111 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 112 return err 113 } 114 115 return nil 116 }