Documentation ¶
Overview ¶
Package server is a generated GoMock package.
Index ¶
- func ClientVersionCheckMiddleware(h http.Handler, rng VersionRange) http.Handler
- func CompressionLevel(level int) func(*serverConfig)
- func NewRouter(c Controller) *mux.Router
- func PanicMiddleware(h http.Handler) http.Handler
- type Controller
- type MockController
- func (m *MockController) CreateBook(ctx context.Context, i *models.Book) (*models.Book, error)
- func (m *MockController) EXPECT() *MockControllerMockRecorder
- func (m *MockController) GetAuthors(ctx context.Context, i *models.GetAuthorsInput) (*models.AuthorsResponse, string, error)
- func (m *MockController) GetAuthorsWithPut(ctx context.Context, i *models.GetAuthorsWithPutInput) (*models.AuthorsResponse, string, error)
- 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, int64, error)
- func (m *MockController) HealthCheck(ctx context.Context) error
- func (m *MockController) PutBook(ctx context.Context, i *models.Book) (*models.Book, error)
- type MockControllerMockRecorder
- func (mr *MockControllerMockRecorder) CreateBook(ctx, i interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) GetAuthors(ctx, i interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) GetAuthorsWithPut(ctx, i interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) GetBookByID(ctx, i interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) GetBookByID2(ctx, id interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) GetBooks(ctx, i interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) HealthCheck(ctx interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) PutBook(ctx, i interface{}) *gomock.Call
- type Server
- type VersionRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientVersionCheckMiddleware ¶
func ClientVersionCheckMiddleware(h http.Handler, rng VersionRange) http.Handler
ClientVersionCheckMiddleware checks the client version.
func CompressionLevel ¶
func CompressionLevel(level int) func(*serverConfig)
func NewRouter ¶
func NewRouter(c Controller) *mux.Router
NewRouter returns a mux.Router with no middleware. This is so we can attach additional routes to the router if necessary
Types ¶
type Controller ¶
type Controller interface { // GetAuthors handles GET requests to /authors // Returns response object and the ID of the next page // Gets authors // 200: *models.AuthorsResponse // 400: *models.BadRequest // 500: *models.InternalError // default: client side HTTP errors, for example: context.DeadlineExceeded. GetAuthors(ctx context.Context, i *models.GetAuthorsInput) (*models.AuthorsResponse, string, error) // GetAuthorsWithPut handles PUT requests to /authors // Returns response object and the ID of the next page // Gets authors, but needs to use the body so it's a PUT // 200: *models.AuthorsResponse // 400: *models.BadRequest // 500: *models.InternalError // default: client side HTTP errors, for example: context.DeadlineExceeded. GetAuthorsWithPut(ctx context.Context, i *models.GetAuthorsWithPutInput) (*models.AuthorsResponse, string, error) // GetBooks handles GET requests to /books // Returns response object and the ID of the next page // 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, int64, error) // CreateBook handles POST requests 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) // PutBook handles PUT requests to /books // Puts a book // 200: *models.Book // 400: *models.BadRequest // 500: *models.InternalError // default: client side HTTP errors, for example: context.DeadlineExceeded. PutBook(ctx context.Context, i *models.Book) (*models.Book, error) // GetBookByID handles GET requests 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 handles GET requests 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 handles GET requests 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
}
MockController is a mock of Controller interface.
func NewMockController ¶
func NewMockController(ctrl *gomock.Controller) *MockController
NewMockController creates a new mock instance.
func (*MockController) CreateBook ¶
CreateBook mocks base method.
func (*MockController) EXPECT ¶
func (m *MockController) EXPECT() *MockControllerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockController) GetAuthors ¶
func (m *MockController) GetAuthors(ctx context.Context, i *models.GetAuthorsInput) (*models.AuthorsResponse, string, error)
GetAuthors mocks base method.
func (*MockController) GetAuthorsWithPut ¶
func (m *MockController) GetAuthorsWithPut(ctx context.Context, i *models.GetAuthorsWithPutInput) (*models.AuthorsResponse, string, error)
GetAuthorsWithPut mocks base method.
func (*MockController) GetBookByID ¶
func (m *MockController) GetBookByID(ctx context.Context, i *models.GetBookByIDInput) (*models.Book, error)
GetBookByID mocks base method.
func (*MockController) GetBookByID2 ¶
GetBookByID2 mocks base method.
func (*MockController) GetBooks ¶
func (m *MockController) GetBooks(ctx context.Context, i *models.GetBooksInput) ([]models.Book, int64, error)
GetBooks mocks base method.
func (*MockController) HealthCheck ¶
func (m *MockController) HealthCheck(ctx context.Context) error
HealthCheck mocks base method.
type MockControllerMockRecorder ¶
type MockControllerMockRecorder struct {
// contains filtered or unexported fields
}
MockControllerMockRecorder is the mock recorder for MockController.
func (*MockControllerMockRecorder) CreateBook ¶
func (mr *MockControllerMockRecorder) CreateBook(ctx, i interface{}) *gomock.Call
CreateBook indicates an expected call of CreateBook.
func (*MockControllerMockRecorder) GetAuthors ¶
func (mr *MockControllerMockRecorder) GetAuthors(ctx, i interface{}) *gomock.Call
GetAuthors indicates an expected call of GetAuthors.
func (*MockControllerMockRecorder) GetAuthorsWithPut ¶
func (mr *MockControllerMockRecorder) GetAuthorsWithPut(ctx, i interface{}) *gomock.Call
GetAuthorsWithPut indicates an expected call of GetAuthorsWithPut.
func (*MockControllerMockRecorder) GetBookByID ¶
func (mr *MockControllerMockRecorder) GetBookByID(ctx, i interface{}) *gomock.Call
GetBookByID indicates an expected call of GetBookByID.
func (*MockControllerMockRecorder) GetBookByID2 ¶
func (mr *MockControllerMockRecorder) GetBookByID2(ctx, id interface{}) *gomock.Call
GetBookByID2 indicates an expected call of GetBookByID2.
func (*MockControllerMockRecorder) GetBooks ¶
func (mr *MockControllerMockRecorder) GetBooks(ctx, i interface{}) *gomock.Call
GetBooks indicates an expected call of GetBooks.
func (*MockControllerMockRecorder) HealthCheck ¶
func (mr *MockControllerMockRecorder) HealthCheck(ctx interface{}) *gomock.Call
HealthCheck indicates an expected call of HealthCheck.
func (*MockControllerMockRecorder) PutBook ¶
func (mr *MockControllerMockRecorder) PutBook(ctx, i interface{}) *gomock.Call
PutBook indicates an expected call of PutBook.
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 AttachMiddleware ¶
func AttachMiddleware(router *mux.Router, addr string, m []func(http.Handler) http.Handler, options ...func(*serverConfig)) *Server
AttachMiddleware attaches the given middleware to the router; this is to be used in conjunction with NewServer. It attaches custom middleware passed as arguments as well as the built-in middleware for logging, tracing, and handling panics. It should be noted that the built-in middleware executes first followed by the passed in middleware (in the order specified).
func New ¶
func New(c Controller, addr string, options ...func(*serverConfig)) *Server
New returns a Server that implements the Controller interface. It will start when "Serve" is called.
func NewWithMiddleware ¶
func NewWithMiddleware(c Controller, addr string, m []func(http.Handler) http.Handler, options ...func(*serverConfig)) *Server
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.
type VersionRange ¶
VersionRange decides whether to accept a version.