Init
This commit is contained in:
36
main.go
Normal file
36
main.go
Normal file
@ -0,0 +1,36 @@
|
||||
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))
|
||||
}
|
Reference in New Issue
Block a user