1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00

Added public directory in example

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2015-03-10 17:34:13 -07:00
parent a268e01746
commit d3481ca5a5
4 changed files with 16 additions and 4 deletions

View File

@ -23,7 +23,7 @@ var u = user{
func TestIndex(t *testing.T) {
b := New()
b.Index("example/index.html")
b.Index("example/public/index.html")
r, _ := http.NewRequest("GET", "/", nil)
w := httptest.NewRecorder()
b.ServeHTTP(w, r)
@ -34,8 +34,8 @@ func TestIndex(t *testing.T) {
func TestStatic(t *testing.T) {
b := New()
b.Static("/static", "example/public")
r, _ := http.NewRequest("GET", "/static/main.js", nil)
b.Static("/js", "example/public/js")
r, _ := http.NewRequest("GET", "/js/main.js", nil)
w := httptest.NewRecorder()
b.ServeHTTP(w, r)
if w.Code != 200 {

View File

@ -41,9 +41,9 @@ func getUser(c *bolt.Context) {
func main() {
b := bolt.New()
b.Index("public/index.html")
b.Static("/js", "public/js")
b.Post("/users", createUser)
b.Get("/users", getUsers)
b.Get("/users/:id", getUser)
b.Static("/static", "/tmp")
b.Run(":8080")
}

11
example/public/index.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bolt</title>
</head>
<body>
Hello, Bolt!
<script src="/js/main.js"></script>
</body>
</html>

View File

@ -0,0 +1 @@
console.log("Hello, Bolt!")