-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
51 lines (40 loc) · 1.13 KB
/
config.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
46
47
48
49
50
51
package router
import (
// Packages
server "github.com/mutablelogic/go-server"
)
////////////////////////////////////////////////////////////////////////////////
// TYPES
type Config struct {
Services ServiceConfig `hcl:"services"`
}
type ServiceConfig map[string]struct {
Service server.ServiceEndpoints `hcl:"service"`
Middleware []server.Middleware `hcl:"middleware"`
}
// Ensure interfaces is implemented
var _ server.Plugin = Config{}
///////////////////////////////////////////////////////////////////////////////
// GLOBALS
const (
defaultName = "router"
defaultCap = 10
pathSep = "/"
hostSep = "."
envRequestPrefix = "REQUEST_PREFIX"
envServerName = "SERVER_NAME"
)
///////////////////////////////////////////////////////////////////////////////
// LIFECYCLE
// Name returns the name of the service
func (Config) Name() string {
return defaultName
}
// Description returns the description of the service
func (Config) Description() string {
return "router for http requests"
}
// Create a new router from the configuration
func (c Config) New() (server.Task, error) {
return New(c)
}