aboutsummaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2022-12-17 21:19:49 +0000
committerJulio Capote <jcapote@gmail.com>2022-12-17 21:19:49 +0000
commit7baee5b892afcddb72a575282c6c8983d477ed44 (patch)
tree1dbde5fe9ab9d3d2f46090f0c72fc0246c410879 /http
parent2585e05af116cb95d2d2c36b096345c2b982e39c (diff)
downloadcommunique-7baee5b892afcddb72a575282c6c8983d477ed44.tar.gz
introduce concept of registry, start of webfinger impl
Diffstat (limited to 'http')
-rw-r--r--http/server.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/http/server.go b/http/server.go
index 25c51d8..6d68d0e 100644
--- a/http/server.go
+++ b/http/server.go
@@ -4,13 +4,16 @@ import (
"io"
"net/http"
+ "git.capotej.com/capotej/communique/registry"
"github.com/gin-gonic/gin"
)
-type Server struct{}
+type Server struct {
+ registry *registry.Registry
+}
-func NewServer() *Server {
- return &Server{}
+func NewServer(registry *registry.Registry) *Server {
+ return &Server{registry: registry}
}
func (s *Server) Start(zapWriter io.Writer) {
@@ -20,8 +23,14 @@ func (s *Server) Start(zapWriter io.Writer) {
gin.DefaultWriter = zapWriter // send gin logs to zap
router.GET("/.well-known/webfinger", func(c *gin.Context) {
- // resource := c.Query("resource")
- c.JSON(http.StatusOK, nil)
+ resourceParam := c.Query("resource")
+ resource := s.registry.LookupResource(resourceParam)
+ if resource != nil {
+ c.JSON(http.StatusOK, resource)
+ } else {
+ c.JSON(http.StatusNotFound, nil)
+ }
+
})
router.Run()