Files
goapi-template/main.go
2025-06-09 12:29:24 -06:00

37 lines
696 B
Go

package main
import (
"fmt"
"log"
"net/http"
"os"
"goapi-template/src/router"
)
func main() {
// Get port from environment or use default
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
host := os.Getenv("HOST")
if host == "" {
host = "localhost"
}
// Setup router
mux := router.SetupRoutes()
// Start server
fmt.Printf("Todo API running at http://%s:%s/\n", host, port)
fmt.Println("Available endpoints:")
fmt.Println(" GET /todos - Get all todos")
fmt.Println(" POST /todos - Create todo")
fmt.Println(" PUT /todos/:id - Update todo")
fmt.Println(" DELETE /todos/:id - Delete todo")
log.Fatal(http.ListenAndServe(":"+port, mux))
}