Massive architectural rework

This commit massively overhauls the project's structure to simplify
development. Most parts are now correctly compartmentalized and
dependencies are passed in a sane way rather than global variables
galore xd.
This commit is contained in:
Zoe
2025-05-02 12:15:40 -05:00
parent f4bf2ff5a1
commit c891c24843
50 changed files with 2684 additions and 2410 deletions

35
cmd/daemon/main.go Normal file
View File

@@ -0,0 +1,35 @@
package main
import (
"fmt"
"net/http"
_ "net/http/pprof"
"os"
"github.com/juls0730/flux/internal/handlers"
)
func main() {
fluxServer := handlers.NewServer()
defer fluxServer.Stop()
http.HandleFunc("POST /deploy", fluxServer.DeployNewApp)
http.HandleFunc("GET /apps", fluxServer.GetAllApps)
http.HandleFunc("GET /app/by-name/{name}", fluxServer.GetAppByName)
http.HandleFunc("GET /app/by-id/{id}", fluxServer.GetAppById)
http.HandleFunc("PUT /app/{id}/start", fluxServer.StartApp)
http.HandleFunc("PUT /app/{id}/stop", fluxServer.StopApp)
http.HandleFunc("DELETE /apps", fluxServer.DeleteAllDeploymentsHandler)
http.HandleFunc("DELETE /app/{id}", fluxServer.DeleteDeployHandler)
http.HandleFunc("GET /heartbeat", fluxServer.DaemonInfoHandler)
err := fluxServer.ListenAndServe()
if err != nil {
fmt.Printf("Failed to start server: %v\n", err)
os.Exit(1)
}
}