Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIFixture ¶
type APIFixture struct { Log logr.Logger Server *FakeAPIServer OwnsServer bool URLBase string }
APIFixture is a base struct to implement OpenStack API simulators for the EnvTest.
func (*APIFixture) Cleanup ¶
func (f *APIFixture) Cleanup()
Cleanup stops the embedded http server if it was created by the fixture during setup
func (*APIFixture) Endpoint ¶
func (f *APIFixture) Endpoint() string
Endpoint is the URL the fixture's embedded http server listening on
func (*APIFixture) InternalError ¶ added in v0.2.0
func (f *APIFixture) InternalError(err error, msg string, w http.ResponseWriter, r *http.Request)
InternalError sends a HTTP 500 response Use it if there was an unexpected error during the request processing
func (*APIFixture) LogRequest ¶ added in v0.2.0
func (f *APIFixture) LogRequest(r *http.Request)
LogRequest logs details of the http.Request
func (*APIFixture) UnexpectedRequest ¶ added in v0.2.0
func (f *APIFixture) UnexpectedRequest(w http.ResponseWriter, r *http.Request)
UnexpectedRequest sends a HTTP 500 response. Use it if the request is understood but not implemented by the fixture
type FakeAPIServer ¶
type FakeAPIServer struct {
// contains filtered or unexported fields
}
FakeAPIServer represents an embedded http server to simulate http services
func (*FakeAPIServer) AddHandler ¶ added in v0.2.0
func (s *FakeAPIServer) AddHandler(pattern string, handler func(http.ResponseWriter, *http.Request))
AddHandler adds a function to be called if a request is received for the URL matching the pattern
func (*FakeAPIServer) Cleanup ¶
func (s *FakeAPIServer) Cleanup()
Cleanup stops the embedded http server
func (*FakeAPIServer) Endpoint ¶
func (s *FakeAPIServer) Endpoint() string
Endpoint is the URL the embedded http server listening on
func (*FakeAPIServer) Setup ¶
func (s *FakeAPIServer) Setup(log logr.Logger)
Setup creates and starts the embedded http server on localhost and on a random port
type Handler ¶
type Handler struct { // Pattern is the request URL to handle. If two patters are matching the // same request then the handler for the longer pattern will be executed. // Using the same pattern in two handlers will cause a panic. Pattern string // Func the the function that handles the request by writing a response Func func(http.ResponseWriter, *http.Request) }
Handler defines which URL patter is handled by which function