本文整理匯總了Golang中github.com/paulbellamy/mango.Stack.Run方法的典型用法代碼示例。如果您正苦於以下問題:Golang Stack.Run方法的具體用法?Golang Stack.Run怎麽用?Golang Stack.Run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/paulbellamy/mango.Stack
的用法示例。
在下文中一共展示了Stack.Run方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
// Pull in command line options or defaults if none given
flag.Parse()
f, err := os.OpenFile(*skylib.LogFileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
if err == nil {
defer f.Close()
log.SetOutput(f)
}
skylib.Setup(sName)
homeTmpl = template.MustParse(homeTemplate, nil)
respTmpl = template.MustParse(responseTemplate, nil)
rpc.HandleHTTP()
portString := fmt.Sprintf("%s:%d", *skylib.BindIP, *skylib.Port)
stack := new(mango.Stack)
stack.Address = portString
routes := make(map[string]mango.App)
routes["/"] = homeHandler
routes["/new"] = submitHandler
stack.Middleware(mango.Routing(routes))
stack.Run(nil)
}
示例2: main
func main() {
stack := new(mango.Stack)
stack.Address = ":" + os.Getenv("PORT")
// Route all requests for /goodbye to the Goodbye handler
routes := map[string]mango.App{"/goodbye(.*)": Goodbye}
stack.Middleware(mango.Routing(routes))
// Hello handles all requests not sent to Goodbye
stack.Run(Hello)
}
示例3: StartServer
func StartServer() {
routes := make(map[string]mango.App)
routes["/hello"] = new(mango.Stack).Compile(hello)
routes["/bye"] = new(mango.Stack).Compile(bye)
testServer := new(mango.Stack)
testServer.Middleware(mango.ShowErrors("<html><body>{Error|html}</body></html>"), mango.Routing(routes))
testServer.Address = "localhost:" + Configuration.Server_Port
testServer.Run(routeNotFound)
fmt.Printf("Running server on: %s\n", testServer.Address)
}
示例4: main
func main() {
// Pull in command line options or defaults if none given
flag.Parse()
skylib.NewAgent().Start()
homeTmpl = template.MustParse(homeTemplate, nil)
respTmpl = template.MustParse(responseTemplate, nil)
portString := fmt.Sprintf("%s:%d", *skylib.BindIP, *skylib.Port)
stack := new(mango.Stack)
stack.Address = portString
routes := make(map[string]mango.App)
routes["/"] = homeHandler
routes["/new"] = submitHandler
stack.Middleware(mango.Routing(routes))
stack.Run(nil)
}
示例5: main
func main() {
stack := new(mango.Stack)
stack.Address = ":3000"
stack.Middleware(mango.ShowErrors(""))
stack.Run(pact.Producer)
}