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
43057a2f
Commit
43057a2f
authored
Nov 10, 2013
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #284
parent
9446563e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
7 deletions
+4
-7
router.go
router.go
+2
-0
router_test.go
router_test.go
+2
-7
No files found.
router.go
View file @
43057a2f
...
...
@@ -461,6 +461,8 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
file
:=
staticDir
+
r
.
URL
.
Path
[
len
(
prefix
)
:
]
finfo
,
err
:=
os
.
Stat
(
file
)
if
err
!=
nil
{
Warn
(
err
)
http
.
NotFound
(
w
,
r
)
return
}
//if the request is dir and DirectoryIndex is false then
...
...
router_test.go
View file @
43057a2f
package
beego
import
(
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"testing"
)
...
...
@@ -143,16 +141,13 @@ func TestNotFound(t *testing.T) {
// TestStatic tests the ability to serve static
// content from the filesystem
func
TestStatic
(
t
*
testing
.
T
)
{
r
,
_
:=
http
.
NewRequest
(
"GET"
,
"/
router_test.go
"
,
nil
)
r
,
_
:=
http
.
NewRequest
(
"GET"
,
"/
static/js/jquery.js
"
,
nil
)
w
:=
httptest
.
NewRecorder
()
pwd
,
_
:=
os
.
Getwd
()
handler
:=
NewControllerRegistor
()
SetStaticPath
(
"/"
,
pwd
)
handler
.
ServeHTTP
(
w
,
r
)
testFile
,
_
:=
ioutil
.
ReadFile
(
pwd
+
"/routes_test.go"
)
if
w
.
Body
.
String
()
!=
string
(
testFile
)
{
if
w
.
Code
!=
404
{
t
.
Errorf
(
"handler.Static failed to serve file"
)
}
}
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