-
Notifications
You must be signed in to change notification settings - Fork 0
/
jitsi.go
47 lines (40 loc) · 1.08 KB
/
jitsi.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"log"
"net/http"
"net/url"
"text/template"
"github.com/SUASecLab/workadventure_admin_extensions/extensions"
)
type JitsiData struct {
JitsiUrl string
RoomName string
Jwt string
UserName string
}
func createJitsiInstance(w http.ResponseWriter, r *http.Request) {
roomName := url.QueryEscape(r.URL.Query().Get("roomName"))
userName := url.QueryEscape(r.URL.Query().Get("userName"))
receivedToken := url.QueryEscape(r.URL.Query().Get("token"))
issuance, err := extensions.IssueToken("http://" + sidecarUrl + "/issuance?name=" + userName + "&token=" + receivedToken)
if err != nil {
log.Println("Could not get Jitsi token: ", err)
return
}
jitsiData := JitsiData{
JitsiUrl: jitsiUrl,
RoomName: roomName,
Jwt: string(issuance.Token),
UserName: userName,
}
tmpl, err := template.ParseFiles("./templates/jitsi.html")
if err != nil {
http.Error(w, "Template file is missing", http.StatusInternalServerError)
log.Println("Template file not present")
return
}
err = tmpl.Execute(w, jitsiData)
if err != nil {
log.Println(err.Error())
}
}