1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-10 00:29:01 +02:00
kratos/examples/ws/main.go

29 lines
524 B
Go
Raw Normal View History

2021-04-22 05:03:56 +02:00
package main
import (
"log"
"github.com/go-kratos/kratos/examples/ws/handler"
"github.com/go-kratos/kratos/v2"
transhttp "github.com/go-kratos/kratos/v2/transport/http"
"github.com/gorilla/mux"
)
func main() {
router := mux.NewRouter()
router.HandleFunc("/ws", handler.WsHandler)
httpSrv := transhttp.NewServer(transhttp.Address(":8080"))
httpSrv.HandlePrefix("/", router)
app := kratos.New(
kratos.Name("ws"),
kratos.Server(
httpSrv,
),
)
if err := app.Run(); err != nil {
log.Println(err)
}
}