Documentation
¶
Index ¶
- type Endpoint
- func DeleteEndpoint(route string, handlers ...httpx.Handler) Endpoint
- func DeleteEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint
- func GetEndpoint(route string, handlers ...httpx.Handler) Endpoint
- func GetEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint
- func PatchEndpoint(route string, handlers ...httpx.Handler) Endpoint
- func PatchEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint
- func PostEndpoint(route string, handlers ...httpx.Handler) Endpoint
- func PostEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint
- func PutEndpoint(route string, handlers ...httpx.Handler) Endpoint
- func PutEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint
- type FakeService
- func (f *FakeService) AssertEndpointsCalled(t ServiceTestingT)
- func (f *FakeService) AssertEndpointsCalledN(t ServiceTestingT, n int)
- func (f *FakeService) AssertEndpointsCalledOnce(t ServiceTestingT)
- func (f *FakeService) AssertEndpointsNotCalled(t ServiceTestingT)
- func (f *FakeService) AssertHandlersCalled(t ServiceTestingT)
- func (f *FakeService) AssertHandlersCalledN(t ServiceTestingT, n int)
- func (f *FakeService) AssertHandlersCalledOnce(t ServiceTestingT)
- func (f *FakeService) AssertHandlersNotCalled(t ServiceTestingT)
- func (f *FakeService) AssertInternalServerErrorHandlerCalled(t ServiceTestingT)
- func (f *FakeService) AssertInternalServerErrorHandlerCalledN(t ServiceTestingT, n int)
- func (f *FakeService) AssertInternalServerErrorHandlerCalledOnce(t ServiceTestingT)
- func (f *FakeService) AssertInternalServerErrorHandlerNotCalled(t ServiceTestingT)
- func (f *FakeService) AssertMalformedRequestHandlerCalled(t ServiceTestingT)
- func (f *FakeService) AssertMalformedRequestHandlerCalledN(t ServiceTestingT, n int)
- func (f *FakeService) AssertMalformedRequestHandlerCalledOnce(t ServiceTestingT)
- func (f *FakeService) AssertMalformedRequestHandlerNotCalled(t ServiceTestingT)
- func (f *FakeService) AssertMethodNotAllowedHandlerCalled(t ServiceTestingT)
- func (f *FakeService) AssertMethodNotAllowedHandlerCalledN(t ServiceTestingT, n int)
- func (f *FakeService) AssertMethodNotAllowedHandlerCalledOnce(t ServiceTestingT)
- func (f *FakeService) AssertMethodNotAllowedHandlerNotCalled(t ServiceTestingT)
- func (f *FakeService) AssertNameCalled(t ServiceTestingT)
- func (f *FakeService) AssertNameCalledN(t ServiceTestingT, n int)
- func (f *FakeService) AssertNameCalledOnce(t ServiceTestingT)
- func (f *FakeService) AssertNameNotCalled(t ServiceTestingT)
- func (f *FakeService) AssertRedirectHandlerCalled(t ServiceTestingT)
- func (f *FakeService) AssertRedirectHandlerCalledN(t ServiceTestingT, n int)
- func (f *FakeService) AssertRedirectHandlerCalledOnce(t ServiceTestingT)
- func (f *FakeService) AssertRedirectHandlerNotCalled(t ServiceTestingT)
- func (_f2 *FakeService) Endpoints() (ident1 []Endpoint)
- func (f *FakeService) EndpointsCalled() bool
- func (f *FakeService) EndpointsCalledN(n int) bool
- func (f *FakeService) EndpointsCalledOnce() bool
- func (f *FakeService) EndpointsNotCalled() bool
- func (_f3 *FakeService) Handlers() (ident1 []httpx.Handler)
- func (f *FakeService) HandlersCalled() bool
- func (f *FakeService) HandlersCalledN(n int) bool
- func (f *FakeService) HandlersCalledOnce() bool
- func (f *FakeService) HandlersNotCalled() bool
- func (_f7 *FakeService) InternalServerErrorHandler() (ident1 httpx.ErrorHandler)
- func (f *FakeService) InternalServerErrorHandlerCalled() bool
- func (f *FakeService) InternalServerErrorHandlerCalledN(n int) bool
- func (f *FakeService) InternalServerErrorHandlerCalledOnce() bool
- func (f *FakeService) InternalServerErrorHandlerNotCalled() bool
- func (_f4 *FakeService) MalformedRequestHandler() (ident1 httpx.Handler)
- func (f *FakeService) MalformedRequestHandlerCalled() bool
- func (f *FakeService) MalformedRequestHandlerCalledN(n int) bool
- func (f *FakeService) MalformedRequestHandlerCalledOnce() bool
- func (f *FakeService) MalformedRequestHandlerNotCalled() bool
- func (_f5 *FakeService) MethodNotAllowedHandler() (ident1 httpx.Handler)
- func (f *FakeService) MethodNotAllowedHandlerCalled() bool
- func (f *FakeService) MethodNotAllowedHandlerCalledN(n int) bool
- func (f *FakeService) MethodNotAllowedHandlerCalledOnce() bool
- func (f *FakeService) MethodNotAllowedHandlerNotCalled() bool
- func (_f1 *FakeService) Name() (ident1 string)
- func (f *FakeService) NameCalled() bool
- func (f *FakeService) NameCalledN(n int) bool
- func (f *FakeService) NameCalledOnce() bool
- func (f *FakeService) NameNotCalled() bool
- func (_f6 *FakeService) RedirectHandler() (ident1 httpx.Handler)
- func (f *FakeService) RedirectHandlerCalled() bool
- func (f *FakeService) RedirectHandlerCalledN(n int) bool
- func (f *FakeService) RedirectHandlerCalledOnce() bool
- func (f *FakeService) RedirectHandlerNotCalled() bool
- func (f *FakeService) Reset()
- type Pipeline
- type Policy
- type Service
- type ServiceAdapter
- func (s *ServiceAdapter) Handlers() []httpx.Handler
- func (s *ServiceAdapter) InternalServerErrorHandler() httpx.ErrorHandler
- func (s *ServiceAdapter) MalformedRequestHandler() httpx.Handler
- func (s *ServiceAdapter) MethodNotAllowedHandler() httpx.Handler
- func (s *ServiceAdapter) RedirectHandler() httpx.Handler
- type ServiceEndpointsInvocation
- type ServiceHandlersInvocation
- type ServiceInternalServerErrorHandlerInvocation
- type ServiceMalformedRequestHandlerInvocation
- type ServiceMethodNotAllowedHandlerInvocation
- type ServiceNameInvocation
- type ServiceRedirectHandlerInvocation
- type ServiceTestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
type Endpoint struct {
Route string // the absolute URL path for this endpoint
Head *Pipeline // HEAD method pipeline
Get *Pipeline // GET method pipeline
Put *Pipeline // PUT method pipeline
Post *Pipeline // POST method pipeline
Patch *Pipeline // PATCH method pipeline
Delete *Pipeline // DELETE method pipeline
Connect *Pipeline // CONNECT method pipeline
Options *Pipeline // OPTIONS method pipeline
Trace *Pipeline // TRACE method pipeline
}
Endpoint is collection of pipelines for a route (URL path), one for each HTTP method. Only supported methods should have pipelines, but at least one pipleline is requried.
func DeleteEndpoint ¶ added in v0.3.0
DeleteEndpoint returns an Endpoint configured for the given route with the DELETE pipeline using the given handlers.
func DeleteEndpointWithPolicy ¶ added in v0.3.0
DeleteEndpointWithPolicy returns an Endpoint configured for the given route, with the given policy and the DELETE pipeline using the given handlers.
func GetEndpoint ¶ added in v0.3.0
GetEndpoint returns an Endpoint configured for the given route with the GET pipeline using the given handlers.
func GetEndpointWithPolicy ¶ added in v0.3.0
GetEndpointWithPolicy returns an Endpoint configured for the given route, with the given policy and the GET pipeline using the given handlers.
func PatchEndpoint ¶ added in v0.3.0
PatchEndpoint returns an Endpoint configured for the given route with the PATCH pipeline using the given handlers.
func PatchEndpointWithPolicy ¶ added in v0.3.0
PatchEndpointWithPolicy returns an Endpoint configured for the given route, with the given policy and the PATCH pipeline using the given handlers.
func PostEndpoint ¶ added in v0.3.0
PostEndpoint returns an Endpoint configured for the given route with the POST pipeline using the given handlers.
func PostEndpointWithPolicy ¶ added in v0.3.0
PostEndpointWithPolicy returns an Endpoint configured for the given route, with the given policy and the POST pipeline using the given handlers.
func PutEndpoint ¶ added in v0.3.0
PutEndpoint returns an Endpoint configured for the given route with the PUT pipeline using the given handlers.
func PutEndpointWithPolicy ¶ added in v0.3.0
PutEndpointWithPolicy returns an Endpoint configured for the given route, with the given policy and the PUT pipeline using the given handlers.
type FakeService ¶
type FakeService struct {
NameHook func() string
EndpointsHook func() []Endpoint
HandlersHook func() []httpx.Handler
MalformedRequestHandlerHook func() httpx.Handler
MethodNotAllowedHandlerHook func() httpx.Handler
RedirectHandlerHook func() httpx.Handler
InternalServerErrorHandlerHook func() httpx.ErrorHandler
NameCalls []*ServiceNameInvocation
EndpointsCalls []*ServiceEndpointsInvocation
HandlersCalls []*ServiceHandlersInvocation
MalformedRequestHandlerCalls []*ServiceMalformedRequestHandlerInvocation
MethodNotAllowedHandlerCalls []*ServiceMethodNotAllowedHandlerInvocation
RedirectHandlerCalls []*ServiceRedirectHandlerInvocation
InternalServerErrorHandlerCalls []*ServiceInternalServerErrorHandlerInvocation
}
FakeService is a mock implementation of Service for testing. Use it in your tests as in this example:
package example
func TestWithService(t *testing.T) {
f := &service.FakeService{
NameHook: func() (ident1 string) {
// ensure parameters meet expections, signal errors using t, etc
return
},
}
// test code goes here ...
// assert state of FakeName ...
f.AssertNameCalledOnce(t)
}
Create anonymous function implementations for only those interface methods that should be called in the code under test. This will force a panic if any unexpected calls are made to FakeName.
func NewFakeServiceDefaultError ¶
func NewFakeServiceDefaultError(t ServiceTestingT) *FakeService
NewFakeServiceDefaultError returns an instance of FakeService with all hooks configured to call t.Error
func NewFakeServiceDefaultFatal ¶
func NewFakeServiceDefaultFatal(t ServiceTestingT) *FakeService
NewFakeServiceDefaultFatal returns an instance of FakeService with all hooks configured to call t.Fatal
func NewFakeServiceDefaultPanic ¶
func NewFakeServiceDefaultPanic() *FakeService
NewFakeServiceDefaultPanic returns an instance of FakeService with all hooks configured to panic
func (*FakeService) AssertEndpointsCalled ¶
func (f *FakeService) AssertEndpointsCalled(t ServiceTestingT)
AssertEndpointsCalled calls t.Error if FakeService.Endpoints was not called
func (*FakeService) AssertEndpointsCalledN ¶
func (f *FakeService) AssertEndpointsCalledN(t ServiceTestingT, n int)
AssertEndpointsCalledN calls t.Error if FakeService.Endpoints was called less than n times
func (*FakeService) AssertEndpointsCalledOnce ¶
func (f *FakeService) AssertEndpointsCalledOnce(t ServiceTestingT)
AssertEndpointsCalledOnce calls t.Error if FakeService.Endpoints was not called exactly once
func (*FakeService) AssertEndpointsNotCalled ¶
func (f *FakeService) AssertEndpointsNotCalled(t ServiceTestingT)
AssertEndpointsNotCalled calls t.Error if FakeService.Endpoints was called
func (*FakeService) AssertHandlersCalled ¶ added in v0.3.0
func (f *FakeService) AssertHandlersCalled(t ServiceTestingT)
AssertHandlersCalled calls t.Error if FakeService.Handlers was not called
func (*FakeService) AssertHandlersCalledN ¶ added in v0.3.0
func (f *FakeService) AssertHandlersCalledN(t ServiceTestingT, n int)
AssertHandlersCalledN calls t.Error if FakeService.Handlers was called less than n times
func (*FakeService) AssertHandlersCalledOnce ¶ added in v0.3.0
func (f *FakeService) AssertHandlersCalledOnce(t ServiceTestingT)
AssertHandlersCalledOnce calls t.Error if FakeService.Handlers was not called exactly once
func (*FakeService) AssertHandlersNotCalled ¶ added in v0.3.0
func (f *FakeService) AssertHandlersNotCalled(t ServiceTestingT)
AssertHandlersNotCalled calls t.Error if FakeService.Handlers was called
func (*FakeService) AssertInternalServerErrorHandlerCalled ¶ added in v0.3.0
func (f *FakeService) AssertInternalServerErrorHandlerCalled(t ServiceTestingT)
AssertInternalServerErrorHandlerCalled calls t.Error if FakeService.InternalServerErrorHandler was not called
func (*FakeService) AssertInternalServerErrorHandlerCalledN ¶ added in v0.3.0
func (f *FakeService) AssertInternalServerErrorHandlerCalledN(t ServiceTestingT, n int)
AssertInternalServerErrorHandlerCalledN calls t.Error if FakeService.InternalServerErrorHandler was called less than n times
func (*FakeService) AssertInternalServerErrorHandlerCalledOnce ¶ added in v0.3.0
func (f *FakeService) AssertInternalServerErrorHandlerCalledOnce(t ServiceTestingT)
AssertInternalServerErrorHandlerCalledOnce calls t.Error if FakeService.InternalServerErrorHandler was not called exactly once
func (*FakeService) AssertInternalServerErrorHandlerNotCalled ¶ added in v0.3.0
func (f *FakeService) AssertInternalServerErrorHandlerNotCalled(t ServiceTestingT)
AssertInternalServerErrorHandlerNotCalled calls t.Error if FakeService.InternalServerErrorHandler was called
func (*FakeService) AssertMalformedRequestHandlerCalled ¶ added in v0.3.0
func (f *FakeService) AssertMalformedRequestHandlerCalled(t ServiceTestingT)
AssertMalformedRequestHandlerCalled calls t.Error if FakeService.MalformedRequestHandler was not called
func (*FakeService) AssertMalformedRequestHandlerCalledN ¶ added in v0.3.0
func (f *FakeService) AssertMalformedRequestHandlerCalledN(t ServiceTestingT, n int)
AssertMalformedRequestHandlerCalledN calls t.Error if FakeService.MalformedRequestHandler was called less than n times
func (*FakeService) AssertMalformedRequestHandlerCalledOnce ¶ added in v0.3.0
func (f *FakeService) AssertMalformedRequestHandlerCalledOnce(t ServiceTestingT)
AssertMalformedRequestHandlerCalledOnce calls t.Error if FakeService.MalformedRequestHandler was not called exactly once
func (*FakeService) AssertMalformedRequestHandlerNotCalled ¶ added in v0.3.0
func (f *FakeService) AssertMalformedRequestHandlerNotCalled(t ServiceTestingT)
AssertMalformedRequestHandlerNotCalled calls t.Error if FakeService.MalformedRequestHandler was called
func (*FakeService) AssertMethodNotAllowedHandlerCalled ¶ added in v0.3.0
func (f *FakeService) AssertMethodNotAllowedHandlerCalled(t ServiceTestingT)
AssertMethodNotAllowedHandlerCalled calls t.Error if FakeService.MethodNotAllowedHandler was not called
func (*FakeService) AssertMethodNotAllowedHandlerCalledN ¶ added in v0.3.0
func (f *FakeService) AssertMethodNotAllowedHandlerCalledN(t ServiceTestingT, n int)
AssertMethodNotAllowedHandlerCalledN calls t.Error if FakeService.MethodNotAllowedHandler was called less than n times
func (*FakeService) AssertMethodNotAllowedHandlerCalledOnce ¶ added in v0.3.0
func (f *FakeService) AssertMethodNotAllowedHandlerCalledOnce(t ServiceTestingT)
AssertMethodNotAllowedHandlerCalledOnce calls t.Error if FakeService.MethodNotAllowedHandler was not called exactly once
func (*FakeService) AssertMethodNotAllowedHandlerNotCalled ¶ added in v0.3.0
func (f *FakeService) AssertMethodNotAllowedHandlerNotCalled(t ServiceTestingT)
AssertMethodNotAllowedHandlerNotCalled calls t.Error if FakeService.MethodNotAllowedHandler was called
func (*FakeService) AssertNameCalled ¶
func (f *FakeService) AssertNameCalled(t ServiceTestingT)
AssertNameCalled calls t.Error if FakeService.Name was not called
func (*FakeService) AssertNameCalledN ¶
func (f *FakeService) AssertNameCalledN(t ServiceTestingT, n int)
AssertNameCalledN calls t.Error if FakeService.Name was called less than n times
func (*FakeService) AssertNameCalledOnce ¶
func (f *FakeService) AssertNameCalledOnce(t ServiceTestingT)
AssertNameCalledOnce calls t.Error if FakeService.Name was not called exactly once
func (*FakeService) AssertNameNotCalled ¶
func (f *FakeService) AssertNameNotCalled(t ServiceTestingT)
AssertNameNotCalled calls t.Error if FakeService.Name was called
func (*FakeService) AssertRedirectHandlerCalled ¶ added in v0.3.0
func (f *FakeService) AssertRedirectHandlerCalled(t ServiceTestingT)
AssertRedirectHandlerCalled calls t.Error if FakeService.RedirectHandler was not called
func (*FakeService) AssertRedirectHandlerCalledN ¶ added in v0.3.0
func (f *FakeService) AssertRedirectHandlerCalledN(t ServiceTestingT, n int)
AssertRedirectHandlerCalledN calls t.Error if FakeService.RedirectHandler was called less than n times
func (*FakeService) AssertRedirectHandlerCalledOnce ¶ added in v0.3.0
func (f *FakeService) AssertRedirectHandlerCalledOnce(t ServiceTestingT)
AssertRedirectHandlerCalledOnce calls t.Error if FakeService.RedirectHandler was not called exactly once
func (*FakeService) AssertRedirectHandlerNotCalled ¶ added in v0.3.0
func (f *FakeService) AssertRedirectHandlerNotCalled(t ServiceTestingT)
AssertRedirectHandlerNotCalled calls t.Error if FakeService.RedirectHandler was called
func (*FakeService) Endpoints ¶
func (_f2 *FakeService) Endpoints() (ident1 []Endpoint)
func (*FakeService) EndpointsCalled ¶
func (f *FakeService) EndpointsCalled() bool
EndpointsCalled returns true if FakeService.Endpoints was called
func (*FakeService) EndpointsCalledN ¶
func (f *FakeService) EndpointsCalledN(n int) bool
EndpointsCalledN returns true if FakeService.Endpoints was called at least n times
func (*FakeService) EndpointsCalledOnce ¶
func (f *FakeService) EndpointsCalledOnce() bool
EndpointsCalledOnce returns true if FakeService.Endpoints was called exactly once
func (*FakeService) EndpointsNotCalled ¶
func (f *FakeService) EndpointsNotCalled() bool
EndpointsNotCalled returns true if FakeService.Endpoints was not called
func (*FakeService) Handlers ¶ added in v0.3.0
func (_f3 *FakeService) Handlers() (ident1 []httpx.Handler)
func (*FakeService) HandlersCalled ¶ added in v0.3.0
func (f *FakeService) HandlersCalled() bool
HandlersCalled returns true if FakeService.Handlers was called
func (*FakeService) HandlersCalledN ¶ added in v0.3.0
func (f *FakeService) HandlersCalledN(n int) bool
HandlersCalledN returns true if FakeService.Handlers was called at least n times
func (*FakeService) HandlersCalledOnce ¶ added in v0.3.0
func (f *FakeService) HandlersCalledOnce() bool
HandlersCalledOnce returns true if FakeService.Handlers was called exactly once
func (*FakeService) HandlersNotCalled ¶ added in v0.3.0
func (f *FakeService) HandlersNotCalled() bool
HandlersNotCalled returns true if FakeService.Handlers was not called
func (*FakeService) InternalServerErrorHandler ¶ added in v0.3.0
func (_f7 *FakeService) InternalServerErrorHandler() (ident1 httpx.ErrorHandler)
func (*FakeService) InternalServerErrorHandlerCalled ¶ added in v0.3.0
func (f *FakeService) InternalServerErrorHandlerCalled() bool
InternalServerErrorHandlerCalled returns true if FakeService.InternalServerErrorHandler was called
func (*FakeService) InternalServerErrorHandlerCalledN ¶ added in v0.3.0
func (f *FakeService) InternalServerErrorHandlerCalledN(n int) bool
InternalServerErrorHandlerCalledN returns true if FakeService.InternalServerErrorHandler was called at least n times
func (*FakeService) InternalServerErrorHandlerCalledOnce ¶ added in v0.3.0
func (f *FakeService) InternalServerErrorHandlerCalledOnce() bool
InternalServerErrorHandlerCalledOnce returns true if FakeService.InternalServerErrorHandler was called exactly once
func (*FakeService) InternalServerErrorHandlerNotCalled ¶ added in v0.3.0
func (f *FakeService) InternalServerErrorHandlerNotCalled() bool
InternalServerErrorHandlerNotCalled returns true if FakeService.InternalServerErrorHandler was not called
func (*FakeService) MalformedRequestHandler ¶ added in v0.3.0
func (_f4 *FakeService) MalformedRequestHandler() (ident1 httpx.Handler)
func (*FakeService) MalformedRequestHandlerCalled ¶ added in v0.3.0
func (f *FakeService) MalformedRequestHandlerCalled() bool
MalformedRequestHandlerCalled returns true if FakeService.MalformedRequestHandler was called
func (*FakeService) MalformedRequestHandlerCalledN ¶ added in v0.3.0
func (f *FakeService) MalformedRequestHandlerCalledN(n int) bool
MalformedRequestHandlerCalledN returns true if FakeService.MalformedRequestHandler was called at least n times
func (*FakeService) MalformedRequestHandlerCalledOnce ¶ added in v0.3.0
func (f *FakeService) MalformedRequestHandlerCalledOnce() bool
MalformedRequestHandlerCalledOnce returns true if FakeService.MalformedRequestHandler was called exactly once
func (*FakeService) MalformedRequestHandlerNotCalled ¶ added in v0.3.0
func (f *FakeService) MalformedRequestHandlerNotCalled() bool
MalformedRequestHandlerNotCalled returns true if FakeService.MalformedRequestHandler was not called
func (*FakeService) MethodNotAllowedHandler ¶ added in v0.3.0
func (_f5 *FakeService) MethodNotAllowedHandler() (ident1 httpx.Handler)
func (*FakeService) MethodNotAllowedHandlerCalled ¶ added in v0.3.0
func (f *FakeService) MethodNotAllowedHandlerCalled() bool
MethodNotAllowedHandlerCalled returns true if FakeService.MethodNotAllowedHandler was called
func (*FakeService) MethodNotAllowedHandlerCalledN ¶ added in v0.3.0
func (f *FakeService) MethodNotAllowedHandlerCalledN(n int) bool
MethodNotAllowedHandlerCalledN returns true if FakeService.MethodNotAllowedHandler was called at least n times
func (*FakeService) MethodNotAllowedHandlerCalledOnce ¶ added in v0.3.0
func (f *FakeService) MethodNotAllowedHandlerCalledOnce() bool
MethodNotAllowedHandlerCalledOnce returns true if FakeService.MethodNotAllowedHandler was called exactly once
func (*FakeService) MethodNotAllowedHandlerNotCalled ¶ added in v0.3.0
func (f *FakeService) MethodNotAllowedHandlerNotCalled() bool
MethodNotAllowedHandlerNotCalled returns true if FakeService.MethodNotAllowedHandler was not called
func (*FakeService) Name ¶
func (_f1 *FakeService) Name() (ident1 string)
func (*FakeService) NameCalled ¶
func (f *FakeService) NameCalled() bool
NameCalled returns true if FakeService.Name was called
func (*FakeService) NameCalledN ¶
func (f *FakeService) NameCalledN(n int) bool
NameCalledN returns true if FakeService.Name was called at least n times
func (*FakeService) NameCalledOnce ¶
func (f *FakeService) NameCalledOnce() bool
NameCalledOnce returns true if FakeService.Name was called exactly once
func (*FakeService) NameNotCalled ¶
func (f *FakeService) NameNotCalled() bool
NameNotCalled returns true if FakeService.Name was not called
func (*FakeService) RedirectHandler ¶ added in v0.3.0
func (_f6 *FakeService) RedirectHandler() (ident1 httpx.Handler)
func (*FakeService) RedirectHandlerCalled ¶ added in v0.3.0
func (f *FakeService) RedirectHandlerCalled() bool
RedirectHandlerCalled returns true if FakeService.RedirectHandler was called
func (*FakeService) RedirectHandlerCalledN ¶ added in v0.3.0
func (f *FakeService) RedirectHandlerCalledN(n int) bool
RedirectHandlerCalledN returns true if FakeService.RedirectHandler was called at least n times
func (*FakeService) RedirectHandlerCalledOnce ¶ added in v0.3.0
func (f *FakeService) RedirectHandlerCalledOnce() bool
RedirectHandlerCalledOnce returns true if FakeService.RedirectHandler was called exactly once
func (*FakeService) RedirectHandlerNotCalled ¶ added in v0.3.0
func (f *FakeService) RedirectHandlerNotCalled() bool
RedirectHandlerNotCalled returns true if FakeService.RedirectHandler was not called
func (*FakeService) Reset ¶ added in v0.3.0
func (f *FakeService) Reset()
type Pipeline ¶
type Pipeline struct {
Policy Policy // customizes automated behavior
Handlers []httpx.Handler // the pipline steps, minimum one
QueryFields []httpx.Field // optional query parameter validation
}
Pipeline is a chain of handlers to be invoked in order on a request. The first non-nil response will be returned to the user agent. If no response is produced an Internal Service Error handler will be invoked.
type Policy ¶
type Policy struct {
// Will malformed query parameters be passed through or
// rejected?
AllowMalformedQueryParameters bool `json:",omitempty"`
// Will unknown query parameters be passed through or
// rejected?
AllowUnknownQueryParameters bool `json:",omitempty"`
// Will requests with missing/extra trailing slash
// be redirected?
AllowTrailingSlashRedirects bool `json:",omitempty"`
// Will URL escaped path parameters be preserved?
PreserveEscapedPathParameters bool `json:",omitempty"`
// The time budget for the pipeline to complete
TimeBudget time.Duration `json:",omitempty"`
}
Policy controls the behavior of per-endpoint request processing before control is passed to the handler.
type Service ¶
type Service interface {
Name() string // Service name. Required.
Endpoints() []Endpoint // Service endpoints. Requried.
// Handlers are optional handlers that should be invoked for
// all endpoints. These will be prepended to all endpoint
// handlers when a service is registered.
Handlers() []httpx.Handler
// MalformedRequestHandler optionally customizes the
// response to the user agent when a malformed request is
// presented.
// If nil the default handler wil return a 400 status code
// with an empty body.
MalformedRequestHandler() httpx.Handler
// MethodNotAllowedHandler optionally customizes the response
// returned to the user agent when an endpoint isn't
// configured to service the method of a request.
// If nil the default handler will return a 405 status code
// with an empty body.
MethodNotAllowedHandler() httpx.Handler
// RedirectHandler optionally customizes the response
// returned to the user agent when an endpoint is configured
// to return a redirect for a path based on a missing or
// extra trailing slash.
// If nil the default handler will return a 303 status code
// for GET and a 307 for other methods, both with an empty
// body.
RedirectHandler() httpx.Handler
// InternalServerErrorHandler optionally customizes the
// response returned to the user agent when the gateway
// encounters an error trying to service a request to an
// endoint of this service.
// If nil the default handler will return a 500 status code
// with an empty body.
InternalServerErrorHandler() httpx.ErrorHandler
}
Service is a logical grouping of related endpoints. Examples of relationships are serving the same product vertical or requiring the same resources. This is an interface instead of a struct so that implementations can store dependencies in the struct.
type ServiceAdapter ¶ added in v0.3.0
type ServiceAdapter struct{}
ServiceAdapter implements several of the methods of the Service interface to simplify buildings services that don't need the customization hooks. Add ServiceAdatper as an anonymous field in your service's struct to inherit these default method implementations.
func (*ServiceAdapter) Handlers ¶ added in v0.3.0
func (s *ServiceAdapter) Handlers() []httpx.Handler
func (*ServiceAdapter) InternalServerErrorHandler ¶ added in v0.3.0
func (s *ServiceAdapter) InternalServerErrorHandler() httpx.ErrorHandler
func (*ServiceAdapter) MalformedRequestHandler ¶ added in v0.3.0
func (s *ServiceAdapter) MalformedRequestHandler() httpx.Handler
func (*ServiceAdapter) MethodNotAllowedHandler ¶ added in v0.3.0
func (s *ServiceAdapter) MethodNotAllowedHandler() httpx.Handler
func (*ServiceAdapter) RedirectHandler ¶ added in v0.3.0
func (s *ServiceAdapter) RedirectHandler() httpx.Handler
type ServiceEndpointsInvocation ¶ added in v0.3.0
type ServiceEndpointsInvocation struct {
Results struct {
Ident1 []Endpoint
}
}
ServiceEndpointsInvocation represents a single call of FakeService.Endpoints
type ServiceHandlersInvocation ¶ added in v0.3.0
ServiceHandlersInvocation represents a single call of FakeService.Handlers
type ServiceInternalServerErrorHandlerInvocation ¶ added in v0.3.0
type ServiceInternalServerErrorHandlerInvocation struct {
Results struct {
Ident1 httpx.ErrorHandler
}
}
ServiceInternalServerErrorHandlerInvocation represents a single call of FakeService.InternalServerErrorHandler
type ServiceMalformedRequestHandlerInvocation ¶ added in v0.3.0
ServiceMalformedRequestHandlerInvocation represents a single call of FakeService.MalformedRequestHandler
type ServiceMethodNotAllowedHandlerInvocation ¶ added in v0.3.0
ServiceMethodNotAllowedHandlerInvocation represents a single call of FakeService.MethodNotAllowedHandler
type ServiceNameInvocation ¶ added in v0.3.0
type ServiceNameInvocation struct {
Results struct {
Ident1 string
}
}
ServiceNameInvocation represents a single call of FakeService.Name
type ServiceRedirectHandlerInvocation ¶ added in v0.3.0
ServiceRedirectHandlerInvocation represents a single call of FakeService.RedirectHandler
type ServiceTestingT ¶ added in v0.3.0
type ServiceTestingT interface {
Error(...interface{})
Errorf(string, ...interface{})
Fatal(...interface{})
Helper()
}
ServiceTestingT represents the methods of "testing".T used by charlatan Fakes. It avoids importing the testing package.