示例
app示例
1package main
2
3import (
4 "github.com/go-zeus/zeus/app"
5 "github.com/go-zeus/zeus/log"
6)
7
8func main() {
9 log.Fatal(app.New().Run(make(chan struct{})))
10}
11
12// curl http://localhost:8080
使用原生路由示例
1package main
2
3import (
4 "github.com/go-zeus/zeus/log"
5 "github.com/go-zeus/zeus/server"
6 "github.com/go-zeus/zeus/service"
7 "net/http"
8)
9
10func main() {
11 mux := http.NewServeMux()
12 mux.HandleFunc("/hi", func(w http.ResponseWriter, r *http.Request) {
13 w.Write([]byte("test server"))
14 })
15 ser := server.New(server.Mux(mux))
16
17 done := make(<-chan struct{})
18 log.Fatal(service.New(service.Server(ser)).Run(done))
19}
20
21// curl http://localhost:8080/hi
发布日期:2000-03-05 01:52 字数:75 用时
tags:Go-Zeus