main.go 496 B

12345678910111213141516171819202122
  1. package main
  2. import (
  3. "log"
  4. "go-common/app/tool/protoc-gen-bm/examples/helloworld/api"
  5. "go-common/app/tool/protoc-gen-bm/examples/helloworld/service"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func main() {
  9. engine := bm.NewServer(nil)
  10. // 注册 middleware 支持正则匹配
  11. engine.Inject("^/echo", func(c *bm.Context) {
  12. // do something
  13. })
  14. s := new(service.Service)
  15. v1.RegisterHelloBMServer(engine, s)
  16. if err := engine.Run("127.0.0.1:8000"); err != nil {
  17. log.Fatal(err)
  18. }
  19. }