2024-01-22 23:10:14 -05:00
|
|
|
// Main entry point for the web app. Does all
|
|
|
|
// the setup, then runs the http server.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"git.burning.moe/celediel/burning.moe/internal/config"
|
|
|
|
"git.burning.moe/celediel/burning.moe/internal/handlers"
|
|
|
|
"git.burning.moe/celediel/burning.moe/internal/render"
|
|
|
|
)
|
|
|
|
|
2024-01-25 02:36:29 -05:00
|
|
|
// App wide config data and such
|
|
|
|
var app config.AppConfig
|
|
|
|
|
2024-01-22 23:10:14 -05:00
|
|
|
func main() {
|
|
|
|
// Initialise app and config
|
2024-01-25 02:36:29 -05:00
|
|
|
app = config.Initialise()
|
2024-01-22 23:10:14 -05:00
|
|
|
|
|
|
|
// Initialise handlers and renderer
|
|
|
|
handlers.Initialise(&app)
|
|
|
|
render.Initialise(&app)
|
|
|
|
|
|
|
|
// Initialise the webserver
|
|
|
|
srv := &http.Server{
|
|
|
|
Addr: fmt.Sprintf(":%d", app.ListenPort),
|
|
|
|
Handler: routes(&app),
|
|
|
|
}
|
|
|
|
|
|
|
|
// and finally, start the server
|
2024-01-27 19:25:17 -05:00
|
|
|
app.Logger.Printf("Starting HTTP Server on port %d", app.ListenPort)
|
|
|
|
err := srv.ListenAndServe()
|
|
|
|
if err != nil {
|
|
|
|
app.Logger.Fatal("Failed to start HTTP Server!", "err", err)
|
|
|
|
}
|
2024-01-22 23:10:14 -05:00
|
|
|
}
|