-
Notifications
You must be signed in to change notification settings - Fork 39
/
handler.go
27 lines (22 loc) · 888 Bytes
/
handler.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
package v2
import (
"github.com/centrifuge/go-centrifuge/httpapi/coreapi"
"github.com/go-chi/chi"
logging "github.com/ipfs/go-log"
)
// handler implements the API handlers.
type handler struct {
srv Service
}
var log = logging.Logger("v2_api")
// Register registers the core apis to the router.
func Register(ctx map[string]interface{}, r chi.Router) {
srv := ctx[BootstrappedService].(Service)
h := handler{srv: srv}
r.Post("/documents", h.CreateDocument)
r.Patch("/documents/{"+coreapi.DocumentIDParam+"}", h.UpdateDocument)
r.Post("/documents/{"+coreapi.DocumentIDParam+"}/commit", h.Commit)
r.Get("/documents/{"+coreapi.DocumentIDParam+"}/pending", h.GetPendingDocument)
r.Get("/documents/{"+coreapi.DocumentIDParam+"}/committed", h.GetCommittedDocument)
r.Get("/documents/{"+coreapi.DocumentIDParam+"}/versions/{"+coreapi.VersionIDParam+"}", h.GetDocumentVersion)
}