-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
64 lines (53 loc) · 1.39 KB
/
app.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
52
53
54
55
56
57
58
59
60
61
62
63
64
package restify
import (
"fmt"
"github.com/getevo/evo/v2"
"github.com/getevo/evo/v2/lib/application"
"github.com/getevo/evo/v2/lib/db"
"github.com/getevo/evo/v2/lib/db/schema"
"github.com/getevo/postman"
"math"
)
var Prefix = "/admin/rest"
var permissionHandler func(permissions Permissions, context *Context) bool
var collection *postman.Collection
type App struct{}
func (app App) Register() error {
if !db.Enabled {
return fmt.Errorf("database is not enabled. restify plugin cannot be registered without a running database. please enable the database in your configuration file")
}
collection = postman.NewCollection("Restify", "")
if postmanAuthType != "none" {
collection.Auth = &postman.Auth{
Type: postman.AuthType(postmanAuthType),
}
}
return nil
}
func (app App) Router() error {
return nil
}
func (app App) WhenReady() error {
for idx, _ := range schema.Models {
var model = schema.Models[idx]
UseModel(model.Sample)
}
app.registerHooks()
var controller Controller
for idx, _ := range resources {
for i, _ := range resources[idx].Actions {
resources[idx].Actions[i].RegisterRouter()
}
}
evo.Get(Prefix+"/models", controller.ModelsHandler)
if postmanRegistered {
evo.Get(Prefix+"/postman", controller.PostmanHandler)
}
return nil
}
func (app App) Priority() application.Priority {
return math.MaxInt32
}
func (app App) Name() string {
return "restify"
}