-
Notifications
You must be signed in to change notification settings - Fork 5
/
router.go
35 lines (29 loc) · 1.33 KB
/
router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package oas
import (
"net/http"
)
// OperationRouter describes an OpenAPI operation router, which can build
// routing based on the specification, given operation handlers, and other
// options.
//
// See "adapter/*" packages for implementations.
type OperationRouter interface {
// WithDocument sets the OpenAPI specification to build routes on.
// It returns the router for convenient chaining.
WithDocument(doc *Document) OperationRouter
// WithMiddleware sets the middleware to build routing with.
// It returns the router for convenient chaining.
WithMiddleware(mws ...Middleware) OperationRouter
// WithOperationHandlers sets operation handlers to build routing with.
// It returns the router for convenient chaining.
WithOperationHandlers(map[string]http.Handler) OperationRouter
// WithMissingOperationHandlerFunc sets the function that will be called
// for each operation that is present in the spec but missing from operation
// handlers. This is completely optional. You can use this method for example
// to simply log a warning or to throw a panic and stop route building.
// This method returns the router for convenient chaining.
WithMissingOperationHandlerFunc(fn func(string)) OperationRouter
// Build builds routing based on the previously provided specification,
// operation handlers, and other options.
Build() error
}