Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
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
beego
Commits
c5a23d5c
Commit
c5a23d5c
authored
Jun 24, 2013
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #81
parent
3578bb32
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
+20
-0
beego.go
beego.go
+1
-0
config.go
config.go
+3
-0
router.go
router.go
+16
-0
No files found.
beego.go
View file @
c5a23d5c
...
...
@@ -39,6 +39,7 @@ var (
UseFcgi
bool
MaxMemory
int64
EnableGzip
bool
// enable gzip
DirectoryIndex
bool
//ebable DirectoryIndex default is false
)
func
init
()
{
...
...
config.go
View file @
c5a23d5c
...
...
@@ -174,6 +174,9 @@ func ParseConfig() (err error) {
if
ar
,
err
:=
AppConfig
.
Bool
(
"enablegzip"
);
err
==
nil
{
EnableGzip
=
ar
}
if
ar
,
err
:=
AppConfig
.
Bool
(
"directoryindex"
);
err
==
nil
{
DirectoryIndex
=
ar
}
}
return
nil
}
router.go
View file @
c5a23d5c
...
...
@@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
"net/url"
"os"
"reflect"
"regexp"
"runtime"
...
...
@@ -317,6 +318,21 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
}
if
strings
.
HasPrefix
(
r
.
URL
.
Path
,
prefix
)
{
file
:=
staticDir
+
r
.
URL
.
Path
[
len
(
prefix
)
:
]
finfo
,
err
:=
os
.
Stat
(
file
)
if
err
!=
nil
{
return
}
//if the request is dir and DirectoryIndex is false then
if
finfo
.
IsDir
()
&&
!
DirectoryIndex
{
if
h
,
ok
:=
ErrorMaps
[
"403"
];
ok
{
h
(
w
,
r
)
}
else
{
w
.
Header
()
.
Set
(
"Content-Type"
,
"text/plain; charset=utf-8"
)
w
.
WriteHeader
(
403
)
fmt
.
Fprintln
(
w
,
"403 Forbidden"
)
return
}
}
http
.
ServeFile
(
w
,
r
,
file
)
w
.
started
=
true
return
...
...
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