You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kratos/examples/ws/main.go

29 lines
524 B

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)
}
}