29 lines
395 B
Go
29 lines
395 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
func main() {
|
|
connectDB()
|
|
|
|
r := chi.NewRouter()
|
|
|
|
r.Use(authMiddleware)
|
|
|
|
// routes
|
|
r.Get("/quotes", getQuotes)
|
|
r.Post("/quotes", createQuote)
|
|
r.Put("/quotes/{id}", updateQuote)
|
|
r.Delete("/quotes/{id}", deleteQuote)
|
|
|
|
port := os.Getenv("PORT")
|
|
if port == "" {
|
|
port = "8080"
|
|
}
|
|
|
|
http.ListenAndServe(":"+port, r)
|
|
} |