aboutsummaryrefslogtreecommitdiff
path: root/http/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'http/server.go')
-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()