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
474a16a7
authored
2014-08-04 15:31:27 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
beego: improve the static file server
1 parent
1d36b19c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
5 deletions
beego.go
router.go
staticfile.go
beego.go
View file @
474a16a
...
...
@@ -383,10 +383,6 @@ func initBeforeHttpRun() {
middleware
.
AppName
=
AppName
middleware
.
RegisterErrorHandler
()
for
u
,
_
:=
range
StaticDir
{
Get
(
u
,
serverStaticRouter
)
Get
(
u
+
"/*"
,
serverStaticRouter
)
}
if
EnableDocs
{
Get
(
"/docs"
,
serverDocs
)
Get
(
"/docs/*"
,
serverDocs
)
...
...
router.go
View file @
474a16a
...
...
@@ -32,7 +32,8 @@ import (
const
(
// default filter execution points
BeforeRouter
=
iota
BeforeStatic
=
iota
BeforeRouter
BeforeExec
AfterExec
FinishRouter
...
...
@@ -577,6 +578,15 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
return
false
}
if
do_filter
(
BeforeStatic
)
{
goto
Admin
}
serverStaticRouter
(
context
)
if
w
.
started
{
goto
Admin
}
// session init
if
SessionOn
{
context
.
Input
.
CruSession
=
GlobalSessions
.
SessionStart
(
w
,
r
)
...
...
staticfile.go
View file @
474a16a
...
...
@@ -22,6 +22,9 @@ import (
)
func
serverStaticRouter
(
ctx
*
context
.
Context
)
{
if
ctx
.
Input
.
Method
()
!=
"GET"
&&
ctx
.
Input
.
Method
()
!=
"HEAD"
{
return
}
requestPath
:=
path
.
Clean
(
ctx
.
Input
.
Request
.
URL
.
Path
)
for
prefix
,
staticDir
:=
range
StaticDir
{
if
len
(
prefix
)
==
0
{
...
...
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