Go-Micro启用web服务

xiaohai 2021-05-09 22:25:39 1808人围观 标签: Go 
简介go-micro框架启用web服务(核心重点不是这里,只是要知道可以这样使用)

go-micro框架启用web服务(核心重点不是这里,只是要知道可以这样使用)

package history

import (
   "github.com/micro/go-micro/web"
 "net/http" )

//微服务开启web服务 func main() {
   server := web.NewService(
      web.Address(":8080"),
  )
   server.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
      writer.Write([]byte("hello"))
   })
   server.Run()
}