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
474a16a7
Commit
474a16a7
authored
Aug 04, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beego: improve the static file server
parent
1d36b19c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
5 deletions
+14
-5
beego.go
beego.go
+0
-4
router.go
router.go
+11
-1
staticfile.go
staticfile.go
+3
-0
No files found.
beego.go
View file @
474a16a7
...
...
@@ -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 @
474a16a7
...
...
@@ -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 @
474a16a7
...
...
@@ -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
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