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
504 B

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