packagecommonimport("github.com/matrix-org/dendrite/clientapi/auth""github.com/matrix-org/dendrite/clientapi/auth/authtypes""github.com/matrix-org/dendrite/clientapi/auth/storage/devices""github.com/matrix-org/util""github.com/prometheus/client_golang/prometheus""net/http")// MakeAuthAPI turns a util.JSONRequestHandler function into an http.Handler which checks the access token in the request.funcMakeAuthAPI(metricsNamestring,deviceDB*devices.Database,ffunc(*http.Request,*authtypes.Device)util.JSONResponse)http.Handler{h:=util.NewJSONRequestHandler(func(req*http.Request)util.JSONResponse{device,resErr:=auth.VerifyAccessToken(req,deviceDB)ifresErr!=nil{return*resErr}returnf(req,device)})returnprometheus.InstrumentHandler(metricsName,util.MakeJSONAPI(h))}// MakeAPI turns a util.JSONRequestHandler function into an http.Handler.funcMakeAPI(metricsNamestring,ffunc(*http.Request)util.JSONResponse)http.Handler{h:=util.NewJSONRequestHandler(f)returnprometheus.InstrumentHandler(metricsName,util.MakeJSONAPI(h))}