-
Notifications
You must be signed in to change notification settings - Fork 5
/
service_provider.go
40 lines (32 loc) · 1.06 KB
/
service_provider.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
package fiber
import (
"github.com/goravel/framework/contracts/config"
"github.com/goravel/framework/contracts/foundation"
"github.com/goravel/framework/contracts/http"
"github.com/goravel/framework/contracts/log"
"github.com/goravel/framework/contracts/validation"
)
const RouteBinding = "goravel.fiber.route"
var (
App foundation.Application
ConfigFacade config.Config
LogFacade log.Log
ValidationFacade validation.Validation
ViewFacade http.View
)
type ServiceProvider struct{}
func (receiver *ServiceProvider) Register(app foundation.Application) {
App = app
app.BindWith(RouteBinding, func(app foundation.Application, parameters map[string]any) (any, error) {
return NewRoute(app.MakeConfig(), parameters)
})
}
func (receiver *ServiceProvider) Boot(app foundation.Application) {
ConfigFacade = app.MakeConfig()
LogFacade = app.MakeLog()
ValidationFacade = app.MakeValidation()
ViewFacade = app.MakeView()
app.Publishes("github.com/goravel/fiber", map[string]string{
"config/cors.go": app.ConfigPath("cors.go"),
})
}