@@ -19,9 +19,9 @@ type API interface {
19
19
20
20
type APIv1 struct {
21
21
engine * gin.Engine
22
- apiGroup * gin.RouterGroup
23
- host string
24
- port string
22
+ ApiGroup * gin.RouterGroup
23
+ Host string
24
+ Port string
25
25
}
26
26
27
27
type APIRouteRegistrar interface {
@@ -33,19 +33,19 @@ type APIOption func(*APIv1)
33
33
func WithGroup (group string ) APIOption {
34
34
// Expects '/v1' as the group
35
35
return func (a * APIv1 ) {
36
- a .apiGroup = a .engine .Group (group )
36
+ a .ApiGroup = a .engine .Group (group )
37
37
}
38
38
}
39
39
40
40
func WithHost (host string ) APIOption {
41
41
return func (a * APIv1 ) {
42
- a .host = host
42
+ a .Host = host
43
43
}
44
44
}
45
45
46
46
func WithPort (port string ) APIOption {
47
47
return func (a * APIv1 ) {
48
- a .port = port
48
+ a .Port = port
49
49
}
50
50
}
51
51
@@ -56,8 +56,8 @@ func New(debug bool, options ...APIOption) *APIv1 {
56
56
once .Do (func () {
57
57
apiInstance = & APIv1 {
58
58
engine : ConfigureRouter (debug ),
59
- host : "localhost" ,
60
- port : "8080" ,
59
+ Host : "localhost" ,
60
+ Port : "8080" ,
61
61
}
62
62
for _ , opt := range options {
63
63
opt (apiInstance )
@@ -87,7 +87,7 @@ func (a *APIv1) Engine() *gin.Engine {
87
87
// @license.name Apache 2.0
88
88
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
89
89
func (a * APIv1 ) Start () error {
90
- address := a .host + ":" + a .port
90
+ address := a .Host + ":" + a .Port
91
91
// Use buffered channel to not block goroutine
92
92
errChan := make (chan error , 1 )
93
93
@@ -132,8 +132,8 @@ func (a *APIv1) AddRoute(method, path string, handler gin.HandlerFunc) {
132
132
133
133
// Check if a specific apiGroup is set
134
134
// If so, add the route to it. Otherwise, add to the main engine.
135
- if a .apiGroup != nil {
136
- addRouteToTarget (a .apiGroup )
135
+ if a .ApiGroup != nil {
136
+ addRouteToTarget (a .ApiGroup )
137
137
} else {
138
138
addRouteToTarget (a .engine )
139
139
}
0 commit comments