Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Added new endpoints to modify settings in-memory (#517)
Mirco T99d7cd3c7329
diff --git a/.gitignore b/.gitignoreindex 99a23c32dd..2bab666eb9 100644--- a/.gitignore+++ b/.gitignore@@ -11,6 +11,10 @@# Output of the go coverage tool, specifically when used with LiteIDE*.out+# ignore IDE specific files+.idea/+*.iml+# Dependency directories (remove the comment below to include it)vendor/diff --git a/controllers/admin/changeStreamName.go b/controllers/admin/changeStreamName.gonew file mode 100644index 0000000000..10384e7b5d--- /dev/null+++ b/controllers/admin/changeStreamName.go@@ -0,0 +1,35 @@+package admin++import (+ "encoding/json"+ "net/http"++ "github.com/owncast/owncast/config"+ "github.com/owncast/owncast/controllers"++ log "github.com/sirupsen/logrus"+)++// ChangeStreamName will change the stream key (in memory).+func ChangeStreamName(w http.ResponseWriter, r *http.Request) {+ if r.Method != "POST" {+ controllers.WriteSimpleResponse(w, false, r.Method+" not supported")+ return+ }++ decoder := json.NewDecoder(r.Body)+ var request changeStreamNameRequest+ err := decoder.Decode(&request)+ if err != nil {+ log.Errorln(err)+ controllers.WriteSimpleResponse(w, false, "")+ return+ }++ config.Config.InstanceDetails.Name = request.Name+ controllers.WriteSimpleResponse(w, true, "changed")+}++type changeStreamNameRequest struct {+ Name string `json:"name"`+}diff --git a/controllers/admin/changeStreamTags.go b/controllers/admin/changeStreamTags.gonew file mode 100644index 0000000000..38bb1b105a--- /dev/null+++ b/controllers/admin/changeStreamTags.go@@ -0,0 +1,35 @@+package admin++import (+ "encoding/json"+ "net/http"++ "github.com/owncast/owncast/config"+ "github.com/owncast/owncast/controllers"++ log "github.com/sirupsen/logrus"+)++// ChangeStreamTags will change the stream key (in memory).+func ChangeStreamTags(w http.ResponseWriter, r *http.Request) {+ if r.Method != "POST" {+ controllers.WriteSimpleResponse(w, false, r.Method+" not supported")+ return+ }++ decoder := json.NewDecoder(r.Body)+ var request changeStreamTagsRequest+ err := decoder.Decode(&request)+ if err != nil {+ log.Errorln(err)+ controllers.WriteSimpleResponse(w, false, "")+ return+ }++ config.Config.InstanceDetails.Tags = request.Tags+ controllers.WriteSimpleResponse(w, true, "changed")+}++type changeStreamTagsRequest struct {+ Tags []string `json:"tags"`+}diff --git a/controllers/admin/changeStreamTitle.go b/controllers/admin/changeStreamTitle.gonew file mode 100644index 0000000000..2a3a95e144--- /dev/null+++ b/controllers/admin/changeStreamTitle.go@@ -0,0 +1,35 @@+package admin++import (+ "encoding/json"+ "net/http"++ "github.com/owncast/owncast/config"+ "github.com/owncast/owncast/controllers"++ log "github.com/sirupsen/logrus"+)++// ChangeStreamTitle will change the stream key (in memory).+func ChangeStreamTitle(w http.ResponseWriter, r *http.Request) {+ if r.Method != "POST" {+ controllers.WriteSimpleResponse(w, false, r.Method+" not supported")+ return+ }++ decoder := json.NewDecoder(r.Body)+ var request changeStreamTitleRequest+ err := decoder.Decode(&request)+ if err != nil {+ log.Errorln(err)+ controllers.WriteSimpleResponse(w, false, "")+ return+ }++ config.Config.InstanceDetails.Title = request.Title+ controllers.WriteSimpleResponse(w, true, "changed")+}++type changeStreamTitleRequest struct {+ Title string `json:"title"`+}diff --git a/openapi.yaml b/openapi.yamlindex 49bb68eaaf..1ff31eab6b 100644--- a/openapi.yaml+++ b/openapi.yaml@@ -607,6 +607,104 @@ paths:type: stringexample: changed+ /api/admin/changetitle:+ post:+ summary: Update Stream Title. Pre-release, do not use.+ description: Change the stream title in memory, but not in the config file.+ tags: ["Admin", "Pre-release"]+ security:+ - AdminBasicAuth: []+ requestBody:+ description: ""+ required: true+ content:+ application/json:+ schema:+ type: object+ properties:+ title:+ type: string+ responses:+ '200':+ description: Title was changed.+ content:+ application/json:+ schema:+ type: object+ properties:+ success:+ type: boolean+ example: true+ message:+ type: string+ example: changed++ /api/admin/changename:+ post:+ summary: Update Stream Name. Pre-release, do not use.+ description: Change the stream name in memory, but not in the config file.+ tags: ["Admin", "Pre-release"]+ security:+ - AdminBasicAuth: []+ requestBody:+ description: ""+ required: true+ content:+ application/json:+ schema:+ type: object+ properties:+ name:+ type: string+ responses:+ '200':+ description: Name was changed.+ content:+ application/json:+ schema:+ type: object+ properties:+ success:+ type: boolean+ example: true+ message:+ type: string+ example: changed++ /api/admin/changetags:+ post:+ summary: Update Stream Tags. Pre-release, do not use.+ description: Change the stream tags in memory, but not in the config file.+ tags: ["Admin", "Pre-release"]+ security:+ - AdminBasicAuth: []+ requestBody:+ description: ""+ required: true+ content:+ application/json:+ schema:+ type: object+ properties:+ tags:+ type: array+ items:+ type: string+ responses:+ '200':+ description: Tags were changed.+ content:+ application/json:+ schema:+ type: object+ properties:+ success:+ type: boolean+ example: true+ message:+ type: string+ example: changed+/api/admin/serverconfig:get:summary: Server Configurationdiff --git a/router/router.go b/router/router.goindex e2850f3088..21481efc72 100644--- a/router/router.go+++ b/router/router.go@@ -61,6 +61,15 @@ func Start() error {// Change the current streaming key in memoryhttp.HandleFunc("/api/admin/changekey", middleware.RequireAdminAuth(admin.ChangeStreamKey))+ // Change the current streaming name in memory+ http.HandleFunc("/api/admin/changename", middleware.RequireAdminAuth(admin.ChangeStreamName))++ // Change the current streaming name in memory+ http.HandleFunc("/api/admin/changetitle", middleware.RequireAdminAuth(admin.ChangeStreamTitle))++ // Change the current streaming name in memory+ http.HandleFunc("/api/admin/changetags", middleware.RequireAdminAuth(admin.ChangeStreamTags))+// Change the extra page content in memoryhttp.HandleFunc("/api/admin/changeextrapagecontent", middleware.RequireAdminAuth(admin.ChangeExtraPageContent))