Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
c5a23d5c
authored
2013-06-24 23:24:13 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix #81
1 parent
3578bb32
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
beego.go
config.go
router.go
beego.go
View file @
c5a23d5
...
...
@@ -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 @
c5a23d5
...
...
@@ -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 @
c5a23d5
...
...
@@ -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
Styling with
Markdown
is supported
Attach a file
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 post a comment