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.
29 lines
524 B
29 lines
524 B
4 years ago
|
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)
|
||
|
}
|
||
|
}
|