Chore: solved some todos
This commit is contained in:
18
main.go
18
main.go
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user