aboutsummaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2023-01-01 21:53:09 +0000
committerJulio Capote <jcapote@gmail.com>2023-01-01 21:53:09 +0000
commitaf4dc7f3f05fad8fe13edf0173a6dee5e4148bd3 (patch)
tree100caca9cb134ab00f73c60c0ed5bb4adabd12fc /http
parent2969956f7eac5fb18fe3bcad24bdc08ee63497af (diff)
downloadcommunique-af4dc7f3f05fad8fe13edf0173a6dee5e4148bd3.tar.gz
rename server to router
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{}