Documentation
¶
Overview ¶
Package mockengine provides a loopback-only, schema-generated OpenAPI contract server.
Index ¶
- type Operation
- type Request
- type Server
- func (s *Server) Errors() []error
- func (s *Server) Listen(url string) error
- func (s *Server) RejectBearer(token string)
- func (s *Server) Requests() []Request
- func (s *Server) RespondWithStatus(t testing.TB, operationID string, status int) []byte
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Operation ¶
type Operation struct {
ID, Method, Path string
Groups []string
Command string
Ignored bool
Args []string
Query map[string]string
// PositionalQuery names the required query parameters, which the CLI
// takes as positional arguments after the path ones, in this order.
PositionalQuery []string
Body []byte
Status int
Response []byte
}
func (Operation) QueryFlags ¶
QueryFlags are the CLI flags of the optional query parameters, sorted.
type Request ¶
type Request struct {
Method, Path, OperationID, Authorization string
Body []byte
Query string
Rejected bool
}
Request includes intentional bearer rejections as well as accepted requests.
type Server ¶
type Server struct {
URL string
Document *openapi3.T
Operations []Operation
// Authenticate, when set, checks bearer tokens, such as against the
// mockauth server that issued them, instead of accepting any.
Authenticate func(token string) error
// Unbounded keeps serving once the request record is full, for a
// long-running mock: it then stops recording.
Unbounded bool
// contains filtered or unexported fields
}
func Build ¶
Build precomputes immutable fixtures serially; no random generator is shared by handlers. Call Listen before serving requests.
func (*Server) Listen ¶
Listen sets the URL the mock is served at; requests are routed under it and under its /api path.
func (*Server) RejectBearer ¶
func (*Server) RespondWithStatus ¶
RespondWithStatus selects a declared response (or its range/default fallback). Bodies are generated from the unchanged contract, never per-operation fixtures.
Click to show internal directories.
Click to hide internal directories.