diff options
author | Julio Capote <jcapote@gmail.com> | 2023-01-08 13:59:00 +0000 |
---|---|---|
committer | Julio Capote <jcapote@gmail.com> | 2023-01-08 13:59:00 +0000 |
commit | 555a2b6ba33afbb43bf84836747e5810eeee365d (patch) | |
tree | d8b5665f2f0dc91dbc78cad2118833b2cf79efc6 /http/router.go | |
parent | a3ae6eaa65744014c225e82d142b217b8ce78488 (diff) | |
download | communique-555a2b6ba33afbb43bf84836747e5810eeee365d.tar.gz |
rename registry to controller
Diffstat (limited to 'http/router.go')
-rw-r--r-- | http/router.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/http/router.go b/http/router.go index 24694b1..5ef172a 100644 --- a/http/router.go +++ b/http/router.go @@ -6,18 +6,18 @@ import ( "io" "net/http" - "git.capotej.com/capotej/communique/registry" + "git.capotej.com/capotej/communique/controller" "github.com/gin-gonic/gin" "go.uber.org/zap" ) type Router struct { - registry *registry.Registry - log *zap.SugaredLogger + controller *controller.Controller + log *zap.SugaredLogger } -func NewRouter(registry *registry.Registry, log *zap.SugaredLogger) *Router { - return &Router{registry: registry, log: log} +func NewRouter(controller *controller.Controller, log *zap.SugaredLogger) *Router { + return &Router{controller: controller, log: log} } func render(c *gin.Context, resource map[string]interface{}, err error) { @@ -41,7 +41,7 @@ func (s *Router) Start(zapWriter io.Writer) { // Webfinger router.GET("/.well-known/webfinger", func(c *gin.Context) { resourceParam := c.Query("resource") - resource, _ := s.registry.Webfinger(resourceParam) + resource, _ := s.controller.Webfinger(resourceParam) if resource != nil { c.Writer.Header().Set("Content-Type", "application/jrd+json") c.JSON(http.StatusOK, resource) @@ -54,7 +54,7 @@ func (s *Router) Start(zapWriter io.Writer) { // Actor router.GET("/actors/:actor", func(c *gin.Context) { actorParam := c.Param("actor") - resource, err := s.registry.Actor(actorParam) + resource, err := s.controller.Actor(actorParam) render(c, resource, err) }) @@ -62,7 +62,7 @@ func (s *Router) Start(zapWriter io.Writer) { // Actor avatar router.GET("/actors/:actor/avatar", func(c *gin.Context) { actorParam := c.Param("actor") - avatarBytes, mediaType, err := s.registry.ActorAvatar(actorParam) + avatarBytes, mediaType, err := s.controller.ActorAvatar(actorParam) if err != nil || avatarBytes == nil || mediaType == "" { c.Data(404, "text/plain", []byte("404 page not found")) } @@ -73,14 +73,14 @@ func (s *Router) Start(zapWriter io.Writer) { // Actor Followers router.GET("/actors/:actor/followers", func(c *gin.Context) { actorParam := c.Param("actor") - resource, err := s.registry.Followers(actorParam) + resource, err := s.controller.Followers(actorParam) render(c, resource, err) }) // Actor Following router.GET("/actors/:actor/following", func(c *gin.Context) { actorParam := c.Param("actor") - resource, err := s.registry.Following(actorParam) + resource, err := s.controller.Following(actorParam) render(c, resource, err) }) @@ -104,7 +104,7 @@ func (s *Router) Start(zapWriter io.Writer) { payload, ).Debug("received inbox item") actorParam := c.Param("actor") - err := s.registry.Inbox(actorParam, c.Request, buf.Bytes()) + err := s.controller.Inbox(actorParam, c.Request, buf.Bytes()) resource := map[string]interface{}{} render(c, resource, err) }) @@ -112,7 +112,7 @@ func (s *Router) Start(zapWriter io.Writer) { // Actor Outbox router.GET("/actors/:actor/outbox", func(c *gin.Context) { actorParam := c.Param("actor") - resource, err := s.registry.OutboxCollection(actorParam) + resource, err := s.controller.OutboxCollection(actorParam) render(c, resource, err) }) @@ -120,7 +120,7 @@ func (s *Router) Start(zapWriter io.Writer) { router.GET("/actors/:actor/activity/:id", func(c *gin.Context) { actorParam := c.Param("actor") idParam := c.Param("id") - resource, err := s.registry.ActivityOrNote("activity", actorParam, idParam) + resource, err := s.controller.ActivityOrNote("activity", actorParam, idParam) render(c, resource, err) }) @@ -128,7 +128,7 @@ func (s *Router) Start(zapWriter io.Writer) { router.GET("/actors/:actor/activity/:id/note", func(c *gin.Context) { actorParam := c.Param("actor") idParam := c.Param("id") - resource, err := s.registry.ActivityOrNote("note", actorParam, idParam) + resource, err := s.controller.ActivityOrNote("note", actorParam, idParam) render(c, resource, err) }) |