Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
d85d61c9
Commit
d85d61c9
authored
Sep 02, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recover and print panics that happen in API server
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
8c652907
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
commands/http/handler.go
commands/http/handler.go
+12
-0
No files found.
commands/http/handler.go
View file @
d85d61c9
...
...
@@ -7,6 +7,8 @@ import (
"io"
"net/http"
"net/url"
"os"
"runtime"
"strconv"
"strings"
...
...
@@ -103,6 +105,16 @@ func (i Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func
(
i
internalHandler
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
log
.
Debug
(
"Incoming API request: "
,
r
.
URL
)
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
log
.
Error
(
r
)
buf
:=
make
([]
byte
,
4096
)
n
:=
runtime
.
Stack
(
buf
,
false
)
fmt
.
Fprintln
(
os
.
Stderr
,
string
(
buf
[
:
n
]))
}
}()
if
!
allowOrigin
(
r
,
i
.
cfg
)
||
!
allowReferer
(
r
,
i
.
cfg
)
{
w
.
WriteHeader
(
http
.
StatusForbidden
)
w
.
Write
([]
byte
(
"403 - Forbidden"
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment