Replaced the gin framwwork with echo

This commit is contained in:
2025-01-13 11:57:48 +01:00
parent 8e2d22b899
commit 034ba35fbb
32 changed files with 348 additions and 266 deletions

35
internal/server/server.go Normal file
View File

@@ -0,0 +1,35 @@
package server
import (
"fmt"
"music-server/pkg/conf"
"net/http"
"os"
"strconv"
"time"
)
type Server struct {
port int
}
func NewServer() *http.Server {
port, _ := strconv.Atoi(os.Getenv("PORT"))
NewServer := &Server{
port: port,
}
conf.SetupDb()
// Declare Server config
server := &http.Server{
Addr: fmt.Sprintf(":%d", NewServer.port),
Handler: NewServer.RegisterRoutes(),
IdleTimeout: time.Minute,
ReadTimeout: 10 * time.Second,
WriteTimeout: 30 * time.Second,
}
return server
}