If you want to run 2 instances in one program, Host Switcher is the feature you're looking for.
1
funcmain(){
2
m1 := macaron.Classic()
3
// Register m1 middlewares and routers.
4
5
m2 := macaron.Classic()
6
// Register m2 middlewares and routers.
7
8
hs := switcher.NewHostSwitcher()
9
// Set instance corresponding to host address.
10
hs.Set("gowalker.org", m1)
11
hs.Set("gogs.io", m2)
12
hs.Run()
13
}
Copied!
By default, this program will listen on ports 4000(for m1) and 4001(for m2) in macaron.DEV mode just for convenience. And only listen on 4000 in macaron.PROD mode.
Dynamic match
In case you have different subdomains that need only one Macaron instance: