-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.go
61 lines (46 loc) · 1.01 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"github.com/webx-top/echo"
mw "github.com/webx-top/echo/middleware"
"github.com/webx-top/echo/subdomains"
)
func main() {
s := subdomains.New()
//-----
// API
//-----
api := echo.New()
api.SetDebug(true)
api.Use(mw.Log())
api.Use(mw.Recover())
s.Add("api@api.localhost:1323", api)
api.Get("/", func(c echo.Context) error {
return c.String("API")
})
api.Get("/geturl/:name", func(c echo.Context) error {
return c.String("GET-URL:" + s.URLByName(`#api#geturl`, c.Param("name")))
}).SetName(`geturl`)
//------
// Blog
//------
blog := echo.New()
blog.SetDebug(true)
blog.Use(mw.Log())
blog.Use(mw.Recover())
s.Add("blog@blog.localhost:1323", blog)
blog.Get("/", func(c echo.Context) error {
return c.String("Blog")
})
//---------
// Website
//---------
site := echo.New()
site.SetDebug(true)
site.Use(mw.Log())
site.Use(mw.Recover())
s.Add("@localhost:1323", site)
site.Get("/", func(c echo.Context) error {
return c.String("Welcome!")
})
s.Run(":1323")
}