Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PanicMiddleware ¶ added in v1.2.3
PanicMiddleware logs any panics. For now, we're continue throwing the panic up the stack so this may crash the process.
func TracingMiddleware ¶ added in v1.2.3
Tracing creates a new span named after the URL path of the request. It places this span in the request context, for use by other handlers via opentracing.SpanFromContext() If a span exists in request headers, the span created by this middleware will be a child of that span.
func WithTracingOpName ¶ added in v1.2.3
WithTracingOpName adds the op name to a context for use by the tracing library. It uses a pointer because it's called below in the stack and the only way to pass the info up is to have it a set a pointer. Even though it doesn't change the context we still have this return a context to maintain the illusion.
Types ¶
type Controller ¶
type Controller interface { // GetBook handles GET requests to /books/{id} // // 200: nil // 400: *models.ExtendedError // 404: *models.NotFound // 500: *models.InternalError // default: client side HTTP errors, for example: context.DeadlineExceeded. GetBook(ctx context.Context, i *models.GetBookInput) 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) EXPECT ¶
func (_m *MockController) EXPECT() *MockControllerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockController) GetBook ¶
func (_m *MockController) GetBook(ctx context.Context, i *models.GetBookInput) error
GetBook mocks base method
type MockControllerMockRecorder ¶ added in v1.5.1
type MockControllerMockRecorder struct {
// contains filtered or unexported fields
}
MockControllerMockRecorder is the mock recorder for MockController
func (*MockControllerMockRecorder) GetBook ¶ added in v1.5.1
func (_mr *MockControllerMockRecorder) GetBook(arg0, arg1 interface{}) *gomock.Call
GetBook indicates an expected call of GetBook
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.