portfolio/api/main.go

33 lines
566 B
Go
Raw Normal View History

2024-02-13 18:45:08 +01:00
package main
import (
"github.com/joho/godotenv"
"log"
"net/http"
api2 "portfolio/api"
"portfolio/database"
)
2024-02-13 18:45:08 +01:00
func main() {
// load .env in runtime environment
err := godotenv.Load()
if err != nil {
log.Fatalf(".env not found: %v", err)
return
}
2024-05-15 15:27:18 +02:00
print("test")
2024-02-13 18:45:08 +01:00
// Create a new request multiplexer
// Take incoming requests and dispatch them to the matching webHandler
2024-02-13 18:45:08 +01:00
mux := http.NewServeMux()
api2.WebRoutes(&mux)
api2.ApiRoutes(&mux)
//connect to database and migrate
database.DB()
2024-02-13 18:45:08 +01:00
// Run the server
http.ListenAndServe(":4002", mux)
}