From 14963269dc63bf038163a851e521d6815ab5f514 Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Sat, 7 Jan 2023 17:54:38 -0500 Subject: avatar support --- http/router.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'http/router.go') diff --git a/http/router.go b/http/router.go index 4c251df..6a43499 100644 --- a/http/router.go +++ b/http/router.go @@ -2,6 +2,7 @@ package http import ( "bytes" + "fmt" "io" "net/http" @@ -57,6 +58,17 @@ func (s *Router) Start(zapWriter io.Writer) { render(c, resource, err) }) + // Actor avatar + router.GET("/actors/:actor/avatar", func(c *gin.Context) { + actorParam := c.Param("actor") + avatarBytes, mediaType, err := s.registry.ActorAvatar(actorParam) + if err != nil || avatarBytes == nil || mediaType == "" { + c.Data(404, "text/plain", []byte("404 page not found")) + } + c.Header("Content-Length", fmt.Sprintf("%d", len(avatarBytes))) + c.Data(200, mediaType, avatarBytes) + }) + // Actor Followers router.GET("/actors/:actor/followers", func(c *gin.Context) { actorParam := c.Param("actor") -- cgit v1.2.3