1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 10:22:19 +00:00

ID is better than Id according to Golang

This commit is contained in:
Yohann D'ANELLO 2020-10-02 21:13:50 +02:00
parent 8eab4dfe22
commit 7ceecad355
3 changed files with 13 additions and 4 deletions

View File

@ -41,7 +41,8 @@ web:
name: Demo
hostname: localhost
favicon: https://www.crans.org/images/favicon.ico
widgetURL: https://example.com/
# You can optionally use {{.Path}} to customize your widget URL
widgetURL: https://example.com/stream_{{.Path}}
viewersCounterRefreshPeriod: 20000
# Configure WebRTC server

View File

@ -1,7 +1,9 @@
package web
import (
"bytes"
"encoding/json"
"html/template"
"log"
"net/http"
@ -45,9 +47,15 @@ func viewerPostHandler(w http.ResponseWriter, r *http.Request) {
func viewerGetHandler(w http.ResponseWriter, r *http.Request) {
// Render template
data := struct {
Path string
Cfg *Options
Cfg *Options
Path string
WidgetURL string
}{Path: r.URL.Path[1:], Cfg: cfg}
b := &bytes.Buffer{}
// Update the WidgetURL with the stream path
_ = template.Must(template.New("").Parse(cfg.WidgetURL)).Execute(b, data)
data.WidgetURL = b.String()
if err := templates.ExecuteTemplate(w, "base", data); err != nil {
log.Println(err.Error())
http.Error(w, "Internal Server Error", http.StatusInternalServerError)

View File

@ -35,7 +35,7 @@
<!-- Chat -->
<div class="col-chat" id="sideWidget">
<iframe src="https://irc.crans.org/web/?join=stream_{{.Path}}&nick=viewer&password=&realname=Viewer"
<iframe src="{{.WidgetURL}}"
title="Chat" sandbox="allow-scripts allow-forms allow-same-origin"></iframe>
</div>
</div>