github.com/djarvur/go-swagger@v0.18.0/examples/task-tracker/client/tasks/create_task_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package tasks 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/task-tracker/models" 17 ) 18 19 // CreateTaskReader is a Reader for the CreateTask structure. 20 type CreateTaskReader struct { 21 formats strfmt.Registry 22 } 23 24 // ReadResponse reads a server response into the received o. 25 func (o *CreateTaskReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 26 switch response.Code() { 27 28 case 201: 29 result := NewCreateTaskCreated() 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 := NewCreateTaskDefault(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 // NewCreateTaskCreated creates a CreateTaskCreated with default headers values 48 func NewCreateTaskCreated() *CreateTaskCreated { 49 return &CreateTaskCreated{} 50 } 51 52 /*CreateTaskCreated handles this case with default header values. 53 54 Task created 55 */ 56 type CreateTaskCreated struct { 57 } 58 59 func (o *CreateTaskCreated) Error() string { 60 return fmt.Sprintf("[POST /tasks][%d] createTaskCreated ", 201) 61 } 62 63 func (o *CreateTaskCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 64 65 return nil 66 } 67 68 // NewCreateTaskDefault creates a CreateTaskDefault with default headers values 69 func NewCreateTaskDefault(code int) *CreateTaskDefault { 70 return &CreateTaskDefault{ 71 _statusCode: code, 72 } 73 } 74 75 /*CreateTaskDefault handles this case with default header values. 76 77 Error response 78 */ 79 type CreateTaskDefault struct { 80 _statusCode int 81 82 XErrorCode string 83 84 Payload *models.Error 85 } 86 87 // Code gets the status code for the create task default response 88 func (o *CreateTaskDefault) Code() int { 89 return o._statusCode 90 } 91 92 func (o *CreateTaskDefault) Error() string { 93 return fmt.Sprintf("[POST /tasks][%d] createTask default %+v", o._statusCode, o.Payload) 94 } 95 96 func (o *CreateTaskDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 97 98 // response header X-Error-Code 99 o.XErrorCode = response.GetHeader("X-Error-Code") 100 101 o.Payload = new(models.Error) 102 103 // response payload 104 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 105 return err 106 } 107 108 return nil 109 }