github.com/djarvur/go-swagger@v0.18.0/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 28 case 200: 29 result := NewFindOK() 30 if err := result.readResponse(response, consumer, o.formats); err != nil { 31 return nil, err 32 } 33 return result, nil 34 35 default: 36 result := NewFindDefault(response.Code()) 37 if err := result.readResponse(response, consumer, o.formats); err != nil { 38 return nil, err 39 } 40 if response.Code()/100 == 2 { 41 return result, nil 42 } 43 return nil, result 44 } 45 } 46 47 // NewFindOK creates a FindOK with default headers values 48 func NewFindOK() *FindOK { 49 return &FindOK{} 50 } 51 52 /*FindOK handles this case with default header values. 53 54 OK 55 */ 56 type FindOK struct { 57 Payload []*models.Item 58 } 59 60 func (o *FindOK) Error() string { 61 return fmt.Sprintf("[GET /][%d] findOK %+v", 200, o.Payload) 62 } 63 64 func (o *FindOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 65 66 // response payload 67 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { 68 return err 69 } 70 71 return nil 72 } 73 74 // NewFindDefault creates a FindDefault with default headers values 75 func NewFindDefault(code int) *FindDefault { 76 return &FindDefault{ 77 _statusCode: code, 78 } 79 } 80 81 /*FindDefault handles this case with default header values. 82 83 error 84 */ 85 type FindDefault struct { 86 _statusCode int 87 88 Payload *models.Error 89 } 90 91 // Code gets the status code for the find default response 92 func (o *FindDefault) Code() int { 93 return o._statusCode 94 } 95 96 func (o *FindDefault) Error() string { 97 return fmt.Sprintf("[GET /][%d] find default %+v", o._statusCode, o.Payload) 98 } 99 100 func (o *FindDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 101 102 o.Payload = new(models.Error) 103 104 // response payload 105 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 106 return err 107 } 108 109 return nil 110 }