Documentation ¶
Index ¶
- type Controller
- type MockController
- func (_m *MockController) CreateBook(ctx context.Context, i *models.Book) (*models.Book, error)
- func (_m *MockController) EXPECT() *_MockControllerRecorder
- func (_m *MockController) GetBookByID(ctx context.Context, i *models.GetBookByIDInput) (*models.Book, error)
- func (_m *MockController) GetBookByID2(ctx context.Context, id string) (*models.Book, error)
- func (_m *MockController) GetBooks(ctx context.Context, i *models.GetBooksInput) ([]models.Book, error)
- func (_m *MockController) HealthCheck(ctx context.Context) error
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface { // GetBooks makes a GET request to /books // Returns a list of books // 200: []models.Book // 400: *models.BadRequest // 500: *models.InternalError // default: client side HTTP errors, for example: context.DeadlineExceeded. GetBooks(ctx context.Context, i *models.GetBooksInput) ([]models.Book, error) // CreateBook makes a POST request to /books // Creates a book // 200: *models.Book // 400: *models.BadRequest // 500: *models.InternalError // default: client side HTTP errors, for example: context.DeadlineExceeded. CreateBook(ctx context.Context, i *models.Book) (*models.Book, error) // GetBookByID makes a GET request to /books/{book_id} // Returns a book // 200: *models.Book // 400: *models.BadRequest // 401: *models.Unathorized // 404: *models.Error // 500: *models.InternalError // default: client side HTTP errors, for example: context.DeadlineExceeded. GetBookByID(ctx context.Context, i *models.GetBookByIDInput) (*models.Book, error) // GetBookByID2 makes a GET request to /books2/{id} // Retrieve a book // 200: *models.Book // 400: *models.BadRequest // 404: *models.Error // 500: *models.InternalError // default: client side HTTP errors, for example: context.DeadlineExceeded. GetBookByID2(ctx context.Context, id string) (*models.Book, error) // HealthCheck makes a GET request to /health/check // // 200: nil // 400: *models.BadRequest // 500: *models.InternalError // default: client side HTTP errors, for example: context.DeadlineExceeded. HealthCheck(ctx context.Context) error }
Controller defines the interface for the swagger-test service.
type MockController ¶
type MockController struct {
// contains filtered or unexported fields
}
Mock of Controller interface
func NewMockController ¶
func NewMockController(ctrl *gomock.Controller) *MockController
func (*MockController) CreateBook ¶
func (*MockController) EXPECT ¶
func (_m *MockController) EXPECT() *_MockControllerRecorder
func (*MockController) GetBookByID ¶
func (_m *MockController) GetBookByID(ctx context.Context, i *models.GetBookByIDInput) (*models.Book, error)
func (*MockController) GetBookByID2 ¶
func (*MockController) GetBooks ¶
func (_m *MockController) GetBooks(ctx context.Context, i *models.GetBooksInput) ([]models.Book, error)
func (*MockController) HealthCheck ¶
func (_m *MockController) HealthCheck(ctx context.Context) error
type Server ¶
type Server struct { // Handler should generally not be changed. It exposed to make testing easier. Handler http.Handler // contains filtered or unexported fields }
Server defines a HTTP server that implements the Controller interface.
func New ¶
func New(c Controller, addr string) *Server
New returns a Server that implements the Controller interface. It will start when "Serve" is called.
func NewWithMiddleware ¶ added in v1.2.0
NewWithMiddleware returns a Server that implemenets the Controller interface. It runs the middleware after the built-in middleware (e.g. logging), but before the controller methods. The middleware is executed in the order specified. The server will start when "Serve" is called.
Click to show internal directories.
Click to hide internal directories.