aboutsummaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
Diffstat (limited to 'http')
-rw-r--r--http/router.go (renamed from http/server.go)26
1 files changed, 20 insertions, 6 deletions
diff --git a/http/server.go b/http/router.go
index 7d18085..204243f 100644
--- a/http/server.go
+++ b/http/router.go
@@ -8,16 +8,15 @@ import (
"github.com/gin-gonic/gin"
)
-// TODO rename to Router and router.go
-type Server struct {
+type Router struct {
registry *registry.Registry
}
-func NewServer(registry *registry.Registry) *Server {
- return &Server{registry: registry}
+func NewRouter(registry *registry.Registry) *Router {
+ return &Router{registry: registry}
}
-func (s *Server) Start(zapWriter io.Writer) {
+func (s *Router) Start(zapWriter io.Writer) {
router := gin.Default()
router.SetTrustedProxies(nil)
gin.DisableConsoleColor()
@@ -78,7 +77,22 @@ func (s *Server) Start(zapWriter io.Writer) {
})
// Single activity
- router.GET("/actors/:actor/outbox/:id/activity", func(c *gin.Context) {
+ router.GET("/actors/:actor/activity/:id", func(c *gin.Context) {
+ actorParam := c.Param("actor")
+ idParam := c.Param("id")
+ var resource map[string]interface{}
+ resource, _ = s.registry.Activity(actorParam, idParam)
+
+ if resource != nil {
+ c.Writer.Header().Set("Content-Type", "application/activity+json")
+ c.JSON(http.StatusOK, resource)
+ } else {
+ c.JSON(http.StatusNotFound, nil)
+ }
+ })
+
+ // Single note
+ router.GET("/actors/:actor/activity/:id/note", func(c *gin.Context) {
actorParam := c.Param("actor")
idParam := c.Param("id")
var resource map[string]interface{}