forked from NARUBROWN/spine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.go
More file actions
44 lines (37 loc) · 871 Bytes
/
app.go
File metadata and controls
44 lines (37 loc) · 871 Bytes
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
package spine
import (
"github.com/NARUBROWN/spine/internal/bootstrap"
"github.com/NARUBROWN/spine/internal/router"
)
type App interface {
// 생성자 선언
Constructor(constructors ...any)
// 라우트 선언
Route(method string, path string, handler any)
// 실행
Run(address string) error
}
type app struct {
constructors []any
routes []router.RouteSpec
}
func New() App {
return &app{}
}
func (a *app) Constructor(constructors ...any) {
a.constructors = append(a.constructors, constructors...)
}
func (a *app) Route(method string, path string, handler any) {
a.routes = append(a.routes, router.RouteSpec{
Method: method,
Path: path,
Handler: handler,
})
}
func (a *app) Run(address string) error {
return bootstrap.Run(bootstrap.Config{
Address: address,
Constructors: a.constructors,
Routes: a.routes,
})
}