server

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2016 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller interface {

	// Health makes a GET request to /health
	//
	// 200: nil
	// 400: *models.BadRequest
	// 404: *models.NotFound
	// 500: *models.InternalError
	// default: client side HTTP errors, for example: context.DeadlineExceeded.
	Health(ctx context.Context, i *models.HealthInput) 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) EXPECT

func (_m *MockController) EXPECT() *_MockControllerRecorder

func (*MockController) Health added in v1.0.0

func (_m *MockController) Health(ctx context.Context, i *models.HealthInput) 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

func NewWithMiddleware(c Controller, addr string, m []func(http.Handler) http.Handler) *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.

func (*Server) Serve

func (s *Server) Serve() error

Serve starts the server. It will return if an error occurs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL