-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_provider.go
38 lines (31 loc) · 1.08 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
package auth
import (
"context"
"github.com/wesleysnt/framework/auth/access"
"github.com/wesleysnt/framework/auth/console"
contractconsole "github.com/wesleysnt/framework/contracts/console"
"github.com/wesleysnt/framework/contracts/foundation"
)
const BindingAuth = "goravel.auth"
const BindingGate = "goravel.gate"
type ServiceProvider struct {
}
func (database *ServiceProvider) Register(app foundation.Application) {
app.Singleton(BindingAuth, func(app foundation.Application) (any, error) {
config := app.MakeConfig()
return NewAuth(config.GetString("auth.defaults.guard"),
app.MakeCache(), config, app.MakeOrm()), nil
})
app.Singleton(BindingGate, func(app foundation.Application) (any, error) {
return access.NewGate(context.Background()), nil
})
}
func (database *ServiceProvider) Boot(app foundation.Application) {
database.registerCommands(app)
}
func (database *ServiceProvider) registerCommands(app foundation.Application) {
app.MakeArtisan().Register([]contractconsole.Command{
console.NewJwtSecretCommand(app.MakeConfig()),
console.NewPolicyMakeCommand(),
})
}