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:
parent
a268e01746
commit
d3481ca5a5
@ -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 {
|
||||
|
@ -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
11
example/public/index.html
Normal 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>
|
1
example/public/js/main.js
Normal file
1
example/public/js/main.js
Normal file
@ -0,0 +1 @@
|
||||
console.log("Hello, Bolt!")
|
Loading…
Reference in New Issue
Block a user