Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
matrix-media-repo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
matrix-media-repo
Commits
fcaee22e
Commit
fcaee22e
authored
1 year ago
by
Travis Ralston
Browse files
Options
Downloads
Patches
Plain Diff
Log a redacted URL during request panics
parent
911a5ffb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/router.go
+2
-1
2 additions, 1 deletion
api/router.go
util/http.go
+7
-0
7 additions, 0 deletions
util/http.go
with
9 additions
and
1 deletion
api/router.go
+
2
−
1
View file @
fcaee22e
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/turt2live/matrix-media-repo/api/_responses"
"github.com/turt2live/matrix-media-repo/api/_responses"
"github.com/turt2live/matrix-media-repo/api/_routers"
"github.com/turt2live/matrix-media-repo/api/_routers"
"github.com/turt2live/matrix-media-repo/util"
)
)
func
buildPrimaryRouter
()
*
httprouter
.
Router
{
func
buildPrimaryRouter
()
*
httprouter
.
Router
{
...
@@ -54,7 +55,7 @@ func finishCorsFn(w http.ResponseWriter, r *http.Request) {
...
@@ -54,7 +55,7 @@ func finishCorsFn(w http.ResponseWriter, r *http.Request) {
}
}
func
panicFn
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
i
interface
{})
{
func
panicFn
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
i
interface
{})
{
logrus
.
Errorf
(
"Panic received on %s %s: %s"
,
r
.
Method
,
r
.
URL
.
String
(
),
i
)
logrus
.
Errorf
(
"Panic received on %s %s: %s"
,
r
.
Method
,
util
.
GetLogSafeUrl
(
r
),
i
)
if
e
,
ok
:=
i
.
(
error
);
ok
{
if
e
,
ok
:=
i
.
(
error
);
ok
{
sentry
.
CaptureException
(
e
)
sentry
.
CaptureException
(
e
)
...
...
This diff is collapsed.
Click to expand it.
util/http.go
+
7
−
0
View file @
fcaee22e
...
@@ -2,6 +2,7 @@ package util
...
@@ -2,6 +2,7 @@ package util
import
(
import
(
"net/http"
"net/http"
"net/url"
"strings"
"strings"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
...
@@ -37,3 +38,9 @@ func GetLogSafeQueryString(r *http.Request) string {
...
@@ -37,3 +38,9 @@ func GetLogSafeQueryString(r *http.Request) string {
return
qs
.
Encode
()
return
qs
.
Encode
()
}
}
func
GetLogSafeUrl
(
r
*
http
.
Request
)
string
{
copyUrl
,
_
:=
url
.
ParseRequestURI
(
r
.
URL
.
String
())
copyUrl
.
RawQuery
=
GetLogSafeQueryString
(
r
)
return
copyUrl
.
String
()
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment