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
9995168f
Commit
9995168f
authored
Dec 14, 2013
by
Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update router.go
parent
02eacb8e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
1 deletion
+44
-1
router.go
router.go
+44
-1
No files found.
router.go
View file @
9995168f
...
...
@@ -473,7 +473,39 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
middleware
.
Exception
(
"403"
,
rw
,
r
,
"403 Forbidden"
)
goto
Admin
}
http
.
ServeFile
(
w
,
r
,
file
)
//This block obtained from (https://github.com/smithfox/beego) - it should probably get merged into astaxie/beego after a pull request
isStaticFileToCompress
:=
false
if
StaticExtensionsToGzip
!=
nil
&&
len
(
StaticExtensionsToGzip
)
>
0
{
for
_
,
statExtension
:=
range
StaticExtensionsToGzip
{
if
strings
.
HasSuffix
(
strings
.
ToLower
(
file
),
strings
.
ToLower
(
statExtension
))
{
isStaticFileToCompress
=
true
break
}
}
}
if
isStaticFileToCompress
{
if
EnableGzip
{
w
.
contentEncoding
=
GetAcceptEncodingZip
(
r
)
}
memzipfile
,
err
:=
OpenMemZipFile
(
file
,
w
.
contentEncoding
)
if
err
!=
nil
{
return
}
w
.
InitHeadContent
(
finfo
.
Size
())
if
strings
.
HasSuffix
(
file
,
".mustache"
)
{
w
.
Header
()
.
Set
(
"Content-Type"
,
"text/html; charset=utf-8"
)
//FIXME: hardcode
}
http
.
ServeContent
(
w
,
r
,
file
,
finfo
.
ModTime
(),
memzipfile
)
}
else
{
http
.
ServeFile
(
w
,
r
,
file
)
}
w
.
started
=
true
goto
Admin
}
...
...
@@ -901,6 +933,7 @@ type responseWriter struct {
writer
http
.
ResponseWriter
started
bool
status
int
contentEncoding
string
}
// Header returns the header map that will be sent by WriteHeader.
...
...
@@ -908,6 +941,16 @@ func (w *responseWriter) Header() http.Header {
return
w
.
writer
.
Header
()
}
func
(
w
*
responseWriter
)
InitHeadContent
(
contentlength
int64
)
{
if
w
.
contentEncoding
==
"gzip"
{
w
.
Header
()
.
Set
(
"Content-Encoding"
,
"gzip"
)
}
else
if
w
.
contentEncoding
==
"deflate"
{
w
.
Header
()
.
Set
(
"Content-Encoding"
,
"deflate"
)
}
else
{
w
.
Header
()
.
Set
(
"Content-Length"
,
strconv
.
FormatInt
(
contentlength
,
10
))
}
}
// Write writes the data to the connection as part of an HTTP reply,
// and sets `started` to true
func
(
w
*
responseWriter
)
Write
(
p
[]
byte
)
(
int
,
error
)
{
...
...
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