Project restructure (#18)

* First pass at restructuring the project; untested but it does compile

* Restructure builds and runs 🎉

* Add the dist folder to the gitignore

* Update core/playlist/monitor.go

* golint and reorganize the monitor.go file

Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
Bradley Hilton
2020-06-22 20:11:56 -05:00
committed by GitHub
parent b0768de6c0
commit 487bd12444
42 changed files with 1309 additions and 1000 deletions

24
controllers/index.go Normal file
View File

@@ -0,0 +1,24 @@
package controllers
import (
"net/http"
"path"
"github.com/gabek/owncast/core"
"github.com/gabek/owncast/router/middleware"
"github.com/gabek/owncast/utils"
)
//IndexHandler handles the default index route
func IndexHandler(w http.ResponseWriter, r *http.Request) {
middleware.EnableCors(&w)
http.ServeFile(w, r, path.Join("webroot", r.URL.Path))
if path.Ext(r.URL.Path) == ".m3u8" {
middleware.DisableCache(&w)
clientID := utils.GenerateClientIDFromRequest(r)
core.SetClientActive(clientID)
}
}

18
controllers/status.go Normal file
View File

@@ -0,0 +1,18 @@
package controllers
import (
"encoding/json"
"net/http"
"github.com/gabek/owncast/core"
"github.com/gabek/owncast/router/middleware"
)
//GetStatus gets the status of the server
func GetStatus(w http.ResponseWriter, r *http.Request) {
middleware.EnableCors(&w)
status := core.GetStatus()
json.NewEncoder(w).Encode(status)
}