mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-15 02:43:09 -06:00
Use *util.JSONResponse for callback return type
This commit is contained in:
parent
90515527b6
commit
e949cc3eda
|
|
@ -175,7 +175,7 @@ func Setup(
|
||||||
).Methods("GET", "POST", "OPTIONS")
|
).Methods("GET", "POST", "OPTIONS")
|
||||||
|
|
||||||
r0mux.Handle("/auth/{authType}/fallback/web?session={sessionID}",
|
r0mux.Handle("/auth/{authType}/fallback/web?session={sessionID}",
|
||||||
common.MakeHTMLAPI("authfallback", func(w http.ResponseWriter, req *http.Request) util.JSONResponse {
|
common.MakeHTMLAPI("authfallback", func(w http.ResponseWriter, req *http.Request) *util.JSONResponse {
|
||||||
vars := mux.Vars(req)
|
vars := mux.Vars(req)
|
||||||
return AuthFallback(w, req, vars["authType"], vars["sessionID"], cfg)
|
return AuthFallback(w, req, vars["authType"], vars["sessionID"], cfg)
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,14 @@ func MakeExternalAPI(metricsName string, f func(*http.Request) util.JSONResponse
|
||||||
|
|
||||||
// MakeHTMLAPI adds Span metrics to the HTML Handler function
|
// MakeHTMLAPI adds Span metrics to the HTML Handler function
|
||||||
// This is used to serve HTML template
|
// This is used to serve HTML template
|
||||||
func MakeHTMLAPI(metricsName string, f func(http.ResponseWriter, *http.Request) util.JSONResponse) http.Handler {
|
func MakeHTMLAPI(metricsName string, f func(http.ResponseWriter, *http.Request) *util.JSONResponse) http.Handler {
|
||||||
withSpan := func(w http.ResponseWriter, req *http.Request) {
|
withSpan := func(w http.ResponseWriter, req *http.Request) {
|
||||||
span := opentracing.StartSpan(metricsName)
|
span := opentracing.StartSpan(metricsName)
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
req = req.WithContext(opentracing.ContextWithSpan(req.Context(), span))
|
req = req.WithContext(opentracing.ContextWithSpan(req.Context(), span))
|
||||||
if err := f(w, req); err != nil {
|
if err := f(w, req); err != nil {
|
||||||
h := util.MakeJSONAPI(util.NewJSONRequestHandler(func(req *http.Request) util.JSONResponse {
|
h := util.MakeJSONAPI(util.NewJSONRequestHandler(func(req *http.Request) util.JSONResponse {
|
||||||
return err
|
return *err
|
||||||
}))
|
}))
|
||||||
h.ServeHTTP(w, req)
|
h.ServeHTTP(w, req)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue