/
types_http_routes.go
45 lines (31 loc) · 1.11 KB
/
types_http_routes.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
36
37
38
39
40
41
42
43
44
45
package types
import gofig "github.com/akutz/gofig/types"
// Router defines an interface to specify a group of routes to add the the
// server.
type Router interface {
// Routes returns all of the router's routes.
Routes() []Route
// Name returns the name of the router.
Name() string
// Init initializes the router.
Init(config gofig.Config)
}
// Route defines an individual API route in the server.
type Route interface {
// Queries add query strings that must match for a route.
Queries(queries ...string) Route
// Middlewares adds middleware to the route.
Middlewares(middlewares ...Middleware) Route
// Name returns the name of the route.
GetName() string
// GetHandler returns the raw function to create the http handler.
GetHandler() APIFunc
// GetMethod returns the http method that the route responds to.
GetMethod() string
// GetPath returns the subpath where the route responds to.
GetPath() string
// GetQueries returns the query strings for which the route should respond.
GetQueries() []string
// GetMiddlewares returns a list of route-specific middleware.
GetMiddlewares() []Middleware
}