1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

impl SRS /api/v1/clients api.

This commit is contained in:
Jacob Su 2024-10-26 23:51:01 +08:00
parent 0b7fbe746e
commit a91d98e1ad
6 changed files with 233 additions and 11 deletions

View file

@ -82,7 +82,7 @@ func (v *srsHTTPAPIServer) Run(ctx context.Context) error {
logger.Df(ctx, "Handle /rtc/v1/whip/ by %v", addr)
mux.HandleFunc("/rtc/v1/whip/", func(w http.ResponseWriter, r *http.Request) {
if err := v.rtc.HandleApiForWHIP(ctx, w, r); err != nil {
apiError(ctx, w, r, err)
apiError(ctx, w, r, err, http.StatusInternalServerError)
}
})
@ -90,10 +90,15 @@ func (v *srsHTTPAPIServer) Run(ctx context.Context) error {
logger.Df(ctx, "Handle /rtc/v1/whep/ by %v", addr)
mux.HandleFunc("/rtc/v1/whep/", func(w http.ResponseWriter, r *http.Request) {
if err := v.rtc.HandleApiForWHEP(ctx, w, r); err != nil {
apiError(ctx, w, r, err)
apiError(ctx, w, r, err, http.StatusInternalServerError)
}
})
logger.Df(ctx, "Proxy /api/ to srs")
mux.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) {
srsLoadBalancer.ProxyHTTPAPI(ctx, w, r)
})
// Run HTTP API server.
v.wg.Add(1)
go func() {
@ -239,7 +244,7 @@ func (v *systemAPI) Run(ctx context.Context) error {
logger.Df(ctx, "Register SRS media server, %+v", server)
return nil
}(); err != nil {
apiError(ctx, w, r, err)
apiError(ctx, w, r, err, http.StatusInternalServerError)
}
type Response struct {