mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 23:13:11 -06:00
Add more stub endpoints
This commit is contained in:
parent
f7f3077cfa
commit
2ed48c54a5
|
|
@ -63,11 +63,6 @@ func Login(req *http.Request, cfg config.ClientAPI) util.JSONResponse {
|
|||
HomeServer: cfg.ServerName,
|
||||
},
|
||||
}
|
||||
} else if req.Method == "OPTIONS" {
|
||||
return util.JSONResponse{
|
||||
Code: 200,
|
||||
JSON: nil,
|
||||
}
|
||||
}
|
||||
return util.JSONResponse{
|
||||
Code: 405,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
|
@ -43,12 +44,72 @@ func Setup(servMux *http.ServeMux, httpClient *http.Client, cfg config.ClientAPI
|
|||
return writers.SendEvent(req, vars["roomID"], vars["eventType"], vars["txnID"], &stateKey, cfg, queryAPI, producer)
|
||||
})),
|
||||
)
|
||||
|
||||
// Stub endpoints required by Riot
|
||||
|
||||
r0mux.Handle("/login",
|
||||
make("login", util.NewJSONRequestHandler(func(req *http.Request) util.JSONResponse {
|
||||
return readers.Login(req, cfg)
|
||||
})),
|
||||
)
|
||||
|
||||
r0mux.Handle("/pushrules/",
|
||||
make("push_rules", util.NewJSONRequestHandler(func(req *http.Request) util.JSONResponse {
|
||||
res := json.RawMessage(`{
|
||||
"global": {
|
||||
"content": [],
|
||||
"override": [],
|
||||
"room": [],
|
||||
"sender": [],
|
||||
"underride": []
|
||||
}
|
||||
}`)
|
||||
return util.JSONResponse{
|
||||
Code: 200,
|
||||
JSON: &res,
|
||||
}
|
||||
})),
|
||||
)
|
||||
|
||||
r0mux.Handle("/user/{userID}/filter",
|
||||
make("make_filter", util.NewJSONRequestHandler(func(req *http.Request) util.JSONResponse {
|
||||
return util.JSONResponse{
|
||||
Code: 200,
|
||||
JSON: struct{}{},
|
||||
}
|
||||
})),
|
||||
)
|
||||
|
||||
r0mux.Handle("/user/{userID}/filter/{filterID}",
|
||||
make("filter", util.NewJSONRequestHandler(func(req *http.Request) util.JSONResponse {
|
||||
return util.JSONResponse{
|
||||
Code: 200,
|
||||
JSON: struct{}{},
|
||||
}
|
||||
})),
|
||||
)
|
||||
|
||||
// Riot user settings
|
||||
|
||||
r0mux.Handle("/profile/{userID}",
|
||||
make("profile", util.NewJSONRequestHandler(func(req *http.Request) util.JSONResponse {
|
||||
return util.JSONResponse{
|
||||
Code: 200,
|
||||
JSON: struct{}{},
|
||||
}
|
||||
})),
|
||||
)
|
||||
|
||||
r0mux.Handle("/account/3pid",
|
||||
make("account_3pid", util.NewJSONRequestHandler(func(req *http.Request) util.JSONResponse {
|
||||
res := json.RawMessage(`{"threepids":[]}`)
|
||||
return util.JSONResponse{
|
||||
Code: 200,
|
||||
JSON: &res,
|
||||
}
|
||||
})),
|
||||
)
|
||||
|
||||
servMux.Handle("/metrics", prometheus.Handler())
|
||||
servMux.Handle("/api/", http.StripPrefix("/api", apiMux))
|
||||
}
|
||||
|
|
|
|||
2
vendor/manifest
vendored
2
vendor/manifest
vendored
|
|
@ -98,7 +98,7 @@
|
|||
{
|
||||
"importpath": "github.com/matrix-org/util",
|
||||
"repository": "https://github.com/matrix-org/util",
|
||||
"revision": "ec8896cd7d9ba6de6143c5f123d1e45413657e7d",
|
||||
"revision": "bc9d5e2d2f68a2ca279fce0fa2f28a91ecf301ed",
|
||||
"branch": "master"
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -111,6 +111,11 @@ func MakeJSONAPI(handler JSONRequestHandler) http.HandlerFunc {
|
|||
logger := GetLogger(req.Context())
|
||||
logger.Print("Incoming request")
|
||||
|
||||
if req.Method == "OPTIONS" {
|
||||
SetCORSHeaders(w)
|
||||
w.WriteHeader(200)
|
||||
return
|
||||
}
|
||||
res := handler.OnIncomingRequest(req)
|
||||
|
||||
// Set common headers returned regardless of the outcome of the request
|
||||
|
|
|
|||
Loading…
Reference in a new issue