Skip to content

Commit

Permalink
Update main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Bulletdev authored Dec 5, 2024
1 parent 1f2f4f7 commit 000eb90
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
package main

import (
"log"
"net/http"

"bullet-cloud-api/internal/handlers"

"github.com/gorilla/handlers"

Check failure on line 7 in cmd/main.go

View workflow job for this annotation

GitHub Actions / build

cannot find module providing package github.com/gorilla/handlers: import lookup disabled by -mod=vendor
"github.com/gorilla/mux"
"bullet-cloud-api/internal/handlers"
)

func main() {
router := mux.NewRouter()

// essa rota deu trabalho, handlers handlers

router.HandleFunc("/products", handlers.GetAllProducts).Methods("GET")
router.HandleFunc("/products", handlers.CreateProduct).Methods("POST")
router.HandleFunc("/products/{id}", handlers.GetProduct).Methods("GET")
router.HandleFunc("/products/{id}", handlers.UpdateProduct).Methods("PUT")
router.HandleFunc("/products/{id}", handlers.DeleteProduct).Methods("DELETE")

// checar a saúde do jovem
router.HandleFunc("/health", handlers.HealthCheck).Methods("GET")

corsHandler := handlers.CORS(
handlers.AllowedOrigins([]string{"http://bulletcloud.com", "http://localhost:3000"}), // adicione seus domínios
handlers.AllowedMethods([]string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}),
handlers.AllowedHeaders([]string{"Content-Type", "Authorization"}),
)

handler := corsHandler(router)

log.Println("Server starting on :8080")
log.Fatal(http.ListenAndServe(":8080", router))
log.Fatal(http.ListenAndServe(":8080", handler))
}

0 comments on commit 000eb90

Please sign in to comment.