Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
c82d7c2d
Commit
c82d7c2d
authored
Jul 06, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
templates: Better error handling for missing files
parent
553d76da
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
middleware/templates/templates.go
middleware/templates/templates.go
+6
-0
No files found.
middleware/templates/templates.go
View file @
c82d7c2d
...
...
@@ -4,6 +4,7 @@ package templates
import
(
"bytes"
"net/http"
"os"
"path"
"path/filepath"
"text/template"
...
...
@@ -35,6 +36,11 @@ func (t Templates) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
// Build the template
tpl
,
err
:=
template
.
ParseFiles
(
filepath
.
Join
(
t
.
Root
,
fpath
))
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
return
http
.
StatusNotFound
,
nil
}
else
if
os
.
IsPermission
(
err
)
{
return
http
.
StatusForbidden
,
nil
}
return
http
.
StatusInternalServerError
,
err
}
...
...
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