mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-12 17:33: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")
|
||||
|
||||
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)
|
||||
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
|
||||
// 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) {
|
||||
span := opentracing.StartSpan(metricsName)
|
||||
defer span.Finish()
|
||||
req = req.WithContext(opentracing.ContextWithSpan(req.Context(), span))
|
||||
if err := f(w, req); err != nil {
|
||||
h := util.MakeJSONAPI(util.NewJSONRequestHandler(func(req *http.Request) util.JSONResponse {
|
||||
return err
|
||||
return *err
|
||||
}))
|
||||
h.ServeHTTP(w, req)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue