first commit

This commit is contained in:
2025-04-23 09:29:23 +07:00
commit 76abeaf8ee
25 changed files with 1323 additions and 0 deletions

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

@@ -0,0 +1,40 @@
package server
import (
"api-poliklinik/internal/database"
"fmt"
"log"
"net/http"
"os"
"strconv"
"time"
_ "github.com/joho/godotenv/autoload"
)
type Server struct {
port int
db database.Service
}
func NewServer() *http.Server {
port, _ := strconv.Atoi(os.Getenv("PORT"))
log.Println("port:", port)
NewServer := &Server{
port: port,
db: database.New(),
}
// 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
}