aboutsummaryrefslogtreecommitdiff
path: root/http/router.go
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2023-01-07 22:54:38 +0000
committerJulio Capote <jcapote@gmail.com>2023-01-07 22:54:38 +0000
commit14963269dc63bf038163a851e521d6815ab5f514 (patch)
treed85f0b5cfebe22924e0068ce1b47b65c79953331 /http/router.go
parentaf05fbea27df62c96b411a941cf5bb612f256e9d (diff)
downloadcommunique-14963269dc63bf038163a851e521d6815ab5f514.tar.gz
avatar support
Diffstat (limited to 'http/router.go')
-rw-r--r--http/router.go12
1 files changed, 12 insertions, 0 deletions
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")