Skip to content

Commit

Permalink
JWT before live777 handler() (#25)
Browse files Browse the repository at this point in the history
* set whipclient publish token=user.token for /wh[i,e]p/{uuid} api.go handler

* add useful space while delete useless blank lines
  • Loading branch information
WinterJack002 authored Nov 26, 2024
1 parent 760d16b commit 0ce867f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 3 additions & 4 deletions server/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/url"

woomMiddleware "woom/server/api/middleware"
"woom/server/api/v1"
v1 "woom/server/api/v1"
"woom/server/helper"
"woom/static"

Expand Down Expand Up @@ -49,16 +49,15 @@ func NewApi(rdb *redis.Client, secret string, live777Url string, live777Token st
r.Post("/room/{roomId}/stream", handle.CreateRoomStream)
r.Patch("/room/{roomId}/stream/{streamId}", handle.UpdateRoomStream)
r.Delete("/room/{roomId}/stream/{streamId}", handle.DestroyRoomStream)
r.HandleFunc("/whip/{uuid}", handler(proxy, live777Url, live777Token))
r.HandleFunc("/whep/{uuid}", handler(proxy, live777Url, live777Token))
})

r.Post("/user/", handle.CreateUser)

//r.Post("/room/{roomId}/message", handle.CreateMessage)
//r.Get("/room/{roomId}/message", handle.ShowMessage)

r.HandleFunc("/whip/{uuid}", handler(proxy, live777Url, live777Token))
r.HandleFunc("/whep/{uuid}", handler(proxy, live777Url, live777Token))

r.Handle("/*", http.StripPrefix("/", http.FileServer(helper.NewSinglePageApp("index.html", http.FS(static.Dist)))))
return r
}
4 changes: 2 additions & 2 deletions webapp/components/use/whip.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useSyncExternalStore } from 'react'
import { event, Context, Data } from './whxp'
import { Stream, StreamState } from '../../lib/api'
import { Stream, StreamState, token } from '../../lib/api'
import { WHIPClient } from 'whip-whep/whip'
import {
deviceNone,
Expand Down Expand Up @@ -188,7 +188,7 @@ class WHIPContext extends Context {

try {
const url = location.origin + `/whip/${id}`
await client.publish(pc, url)
await client.publish(pc, url, token)
} catch (e) {
console.log(e)
userStatus.state = StreamState.Failed
Expand Down
2 changes: 2 additions & 0 deletions webapp/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ export {
delStream,

StreamState,

token,
}

export type {
Expand Down

0 comments on commit 0ce867f

Please sign in to comment.