HEAVY: migrate accounts and logs to service/repo architecture

This commit is contained in:
ari melody 2026-07-31 02:43:45 +01:00
parent 5c255fb34b
commit 49e14b5bc5
Signed by: ari
GPG key ID: CF99829C92678188
37 changed files with 1019 additions and 687 deletions

View file

@ -2,14 +2,15 @@ package view
import (
"arimelody-web/controller"
"arimelody-web/model"
"arimelody-web/model/app"
"arimelody-web/model/twitch"
"arimelody-web/templates"
"fmt"
"net/http"
"os"
)
func IndexHandler(app *model.AppState) http.Handler {
func IndexHandler(app *app.AppState) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodHead {
w.WriteHeader(http.StatusOK)
@ -18,10 +19,10 @@ func IndexHandler(app *model.AppState) http.Handler {
if r.URL.Path == "/" || r.URL.Path == "/index.html" {
type IndexData struct {
TwitchStatus *model.TwitchStreamInfo
TwitchStatus *twitch.StreamInfo
}
var err error
var twitchStatus *model.TwitchStreamInfo = nil
var twitchStatus *twitch.StreamInfo = nil
if app.Twitch != nil && len(app.Config.Twitch.Broadcaster) > 0 {
twitchStatus, err = controller.GetTwitchStatus(app, app.Config.Twitch.Broadcaster)
if err != nil {

View file

@ -1,18 +1,19 @@
package view
import (
"fmt"
"net/http"
"os"
"fmt"
"net/http"
"os"
"arimelody-web/controller"
"arimelody-web/model"
"arimelody-web/templates"
"arimelody-web/controller"
"arimelody-web/model"
"arimelody-web/model/app"
"arimelody-web/templates"
)
// HTTP HANDLER METHODS
func MusicHandler(app *model.AppState) http.Handler {
func MusicHandler(app *app.AppState) http.Handler {
mux := http.NewServeMux()
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@ -33,7 +34,7 @@ func MusicHandler(app *model.AppState) http.Handler {
return mux
}
func ServeCatalog(app *model.AppState) http.Handler {
func ServeCatalog(app *app.AppState) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
releases, err := controller.GetAllReleases(app.DB, true, 0, true)
if err != nil {
@ -55,7 +56,7 @@ func ServeCatalog(app *model.AppState) http.Handler {
})
}
func ServeGateway(app *model.AppState, release *model.Release) http.Handler {
func ServeGateway(app *app.AppState, release *model.Release) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// only allow authorised users to view hidden releases
privileged := false