diff --git a/README.md b/README.md index 8bdc0fb..b8e6220 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ webtransport: ## API接口 -- `/webtransport/play/[streamPath]` 用来播放 -- `/webtransport/push/[streamPath]` 用来推流 +- `/play/[streamPath]` 用来播放 +- `/push/[streamPath]` 用来推流 建立双向流后传输flv格式的数据 \ No newline at end of file diff --git a/main.go b/main.go index cbe1311..40db0c5 100644 --- a/main.go +++ b/main.go @@ -19,7 +19,7 @@ func (c *WebTransportConfig) OnEvent(event any) { case FirstConfig: mux := http.NewServeMux() mux.HandleFunc("/play/", func(w http.ResponseWriter, r *http.Request) { - streamPath := r.URL.Path[5:] + streamPath := r.URL.Path[len("/play/"):] session := r.Body.(*webtransport.Session) session.AcceptSession() defer session.CloseSession() @@ -39,7 +39,7 @@ func (c *WebTransportConfig) OnEvent(event any) { plugin.SubscribeBlock(streamPath, sub) }) mux.HandleFunc("/push/", func(w http.ResponseWriter, r *http.Request) { - streamPath := r.URL.Path[5:] + streamPath := r.URL.Path[len("/push/"):] session := r.Body.(*webtransport.Session) session.AcceptSession() defer session.CloseSession() @@ -57,7 +57,7 @@ func (c *WebTransportConfig) OnEvent(event any) { pub.SetIO(s) pub.ID = strconv.FormatInt(int64(s.StreamID()), 10) if plugin.Publish(streamPath, pub) == nil { - + } }) server := &webtransport.Server{