Chore: solved some todos

This commit is contained in:
Grail Finder
2025-06-12 07:04:20 +03:00
parent 6934b724ae
commit 74b10b8395
10 changed files with 50 additions and 82 deletions

18
main.go
View File

@ -1,20 +1,27 @@
package main
import (
"fmt"
"golias/config"
"golias/handlers"
"log/slog"
"net/http"
"time"
)
// TODO: add config as param
var cfg *config.Config
func init() {
cfg = config.LoadConfigOrDefault("")
}
func ListenToRequests(port string) error {
mux := http.NewServeMux()
server := &http.Server{
Handler: handlers.LogRequests(handlers.GetSession(mux)),
Addr: port,
ReadTimeout: time.Second * 5,
WriteTimeout: 0, // sse streaming
Addr: fmt.Sprintf(":%s", port),
ReadTimeout: time.Second * 5, // TODO: to cfg
WriteTimeout: 0, // sse streaming
}
fs := http.FileServer(http.Dir("assets/"))
mux.Handle("GET /assets/", http.StripPrefix("/assets/", fs))
@ -43,8 +50,7 @@ func ListenToRequests(port string) error {
}
func main() {
port := ":3000"
err := ListenToRequests(port)
err := ListenToRequests(cfg.ServerConfig.Port)
if err != nil {
panic(err)
}