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
f8db8ae9
Commit
f8db8ae9
authored
Nov 12, 2015
by
JessonChan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add some comments
parent
a9881388
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
staticfile.go
staticfile.go
+8
-0
No files found.
staticfile.go
View file @
f8db8ae9
...
...
@@ -127,6 +127,8 @@ func openFile(filePath string, fi os.FileInfo, acceptEncoding string) (bool, str
return
mapFile
.
encoding
!=
""
,
mapFile
.
encoding
,
mapFile
,
nil
}
// isStaticCompress detect static files
func
isStaticCompress
(
filePath
string
)
bool
{
for
_
,
statExtension
:=
range
StaticExtensionsToGzip
{
if
strings
.
HasSuffix
(
strings
.
ToLower
(
filePath
),
strings
.
ToLower
(
statExtension
))
{
...
...
@@ -136,6 +138,8 @@ func isStaticCompress(filePath string) bool {
return
false
}
// searchFile search the file by url path
// if none the static file prefix matches ,return notStaticRequestErr
func
searchFile
(
ctx
*
context
.
Context
)
(
string
,
os
.
FileInfo
,
error
)
{
requestPath
:=
filepath
.
Clean
(
ctx
.
Input
.
Request
.
URL
.
Path
)
// special processing : favicon.ico/robots.txt can be in any static dir
...
...
@@ -171,6 +175,10 @@ func searchFile(ctx *context.Context) (string, os.FileInfo, error) {
return
""
,
nil
,
notStaticRequestErr
}
// lookupFile find the file to serve
// if the file is dir ,search the index.html as default file( MUST NOT A DIR also)
// if the index.html not exist or is a dir, give a forbidden response depending on DirectoryIndex
func
lookupFile
(
ctx
*
context
.
Context
)
(
bool
,
string
,
os
.
FileInfo
,
error
)
{
fp
,
fi
,
err
:=
searchFile
(
ctx
)
if
fp
==
""
||
fi
==
nil
{
...
...
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