~emersion/soju

7da530dfd4324875c32d81e03d5672586cca9cb9 — Simon Ser 3 days ago f07789c srht
Serve sr.ht API metadata
1 files changed, 12 insertions(+), 1 deletions(-)

M server.go
M server.go => server.go +12 -1
@@ 340,6 340,10 @@ type GamjaConfig struct {
	Server GamjaServerConfig `json:"server"`
}

type SrhtAPIMetadata struct {
	Scopes []string `json:"scopes"`
}

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	var srhtAuth *SrhtAuth
	if cookie, _ := req.Cookie("sr.ht.unified-login.v1"); cookie != nil {


@@ 351,7 355,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
		}
	}

	if req.URL.Path == "/config.json" {
	switch req.URL.Path {
	case "/config.json":
		w.Header().Set("Content-Type", "application/json")
		nick := "user"
		if srhtAuth != nil {


@@ 367,6 372,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
			},
		})
		return
	case "/query/api-meta.json":
		w.Header().Set("Content-Type", "application/json")
		json.NewEncoder(w).Encode(SrhtAPIMetadata{
			Scopes: []string{"IRC"},
		})
		return
	}

	conn, err := websocket.Accept(w, req, &websocket.AcceptOptions{