Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
9948228e
Commit
9948228e
authored
Dec 01, 2017
by
Kazumasa Kohtaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set a proper status code before sending an error status page
parent
861d4ae4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
handlers.go
server/handlers.go
+1
-1
templates.go
server/templates.go
+7
-3
No files found.
server/handlers.go
View file @
9948228e
...
...
@@ -996,7 +996,7 @@ func (s *Server) writeAccessToken(w http.ResponseWriter, idToken, accessToken, r
}
func
(
s
*
Server
)
renderError
(
w
http
.
ResponseWriter
,
status
int
,
description
string
)
{
if
err
:=
s
.
templates
.
err
(
w
,
http
.
StatusText
(
status
)
,
description
);
err
!=
nil
{
if
err
:=
s
.
templates
.
err
(
w
,
status
,
description
);
err
!=
nil
{
s
.
logger
.
Errorf
(
"Server template error: %v"
,
err
)
}
}
...
...
server/templates.go
View file @
9948228e
...
...
@@ -226,12 +226,16 @@ func (t *templates) oob(w http.ResponseWriter, code string) error {
return
renderTemplate
(
w
,
t
.
oobTmpl
,
data
)
}
func
(
t
*
templates
)
err
(
w
http
.
ResponseWriter
,
errType
string
,
errMsg
string
)
error
{
func
(
t
*
templates
)
err
(
w
http
.
ResponseWriter
,
errCode
int
,
errMsg
string
)
error
{
w
.
WriteHeader
(
errCode
)
data
:=
struct
{
ErrType
string
ErrMsg
string
}{
errType
,
errMsg
}
return
renderTemplate
(
w
,
t
.
errorTmpl
,
data
)
}{
http
.
StatusText
(
errCode
),
errMsg
}
if
err
:=
t
.
errorTmpl
.
Execute
(
w
,
data
);
err
!=
nil
{
return
fmt
.
Errorf
(
"Error rendering template %s: %s"
,
t
.
errorTmpl
.
Name
(),
err
)
}
return
nil
}
// small io.Writer utility to determine if executing the template wrote to the underlying response writer.
...
...
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