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
package rest
/*
Hello! This file is auto-generated from `docs/src/spec.json`.
For development:
In order to update the generated files, edit this file under the location,
add your struct fields, imports, API definitions and whatever you want, and:
1. run [spec](https://github.com/titpetric/spec) in the same folder,
2. run `./_gen.php` in this folder.
You may edit `module.go`, `module.util.go` or `module_test.go` to
implement your API calls, helper functions and tests. The file `module.go`
is only generated the first time, and will not be overwritten if it exists.
*/
import (
"github.com/go-chi/chi"
"github.com/crusttech/crust/crm/rest/server"
)
func MountRoutes(r chi.Router) {
field := &server.FieldHandlers{Field: Field{}.New()}
module := &server.ModuleHandlers{Module: Module{}.New()}
r.Group(func(r chi.Router) {
r.Use(field.Field.Authenticator())
r.Route("/field", func(r chi.Router) {
r.Get("/", field.List)
r.Get("/{id}", field.Type)
})
})
r.Group(func(r chi.Router) {
r.Use(module.Module.Authenticator())
r.Route("/module", func(r chi.Router) {
r.Get("/", module.List)
r.Post("/", module.Create)
r.Get("/{id}", module.Read)
r.Post("/{id}", module.Edit)
r.Delete("/{id}", module.Delete)
r.Get("/{module}/content", module.ContentList)
r.Post("/{module}/content", module.ContentCreate)
r.Get("/{module}/content/{id}", module.ContentRead)
r.Post("/{module}/content/{id}", module.ContentEdit)
r.Delete("/{module}/content/{id}", module.ContentDelete)
})
})
}