|
1 | 1 | package main |
2 | | - |
| 2 | + |
3 | 3 | import ( |
4 | 4 | "log" |
5 | 5 | "net/http" |
6 | 6 |
|
7 | | - "github.com/gorilla/handlers" |
8 | | - "github.com/gorilla/mux" |
9 | 7 | "bullet-cloud-api/internal/handlers" |
10 | | -) |
| 8 | + |
| 9 | + "github.com/gorilla/mux" |
| 10 | +) |
11 | 11 |
|
12 | 12 | func main() { |
13 | | - router := mux.NewRouter() |
14 | | - |
15 | | - |
| 13 | + router := mux.NewRouter() |
| 14 | + |
| 15 | + // essa rota deu trabalho, handlers handlers |
16 | 16 | router.HandleFunc("/products", handlers.GetAllProducts).Methods("GET") |
17 | 17 | router.HandleFunc("/products", handlers.CreateProduct).Methods("POST") |
18 | 18 | router.HandleFunc("/products/{id}", handlers.GetProduct).Methods("GET") |
19 | 19 | router.HandleFunc("/products/{id}", handlers.UpdateProduct).Methods("PUT") |
20 | 20 | router.HandleFunc("/products/{id}", handlers.DeleteProduct).Methods("DELETE") |
| 21 | + // |
| 22 | + // checar a saúde do jovem |
21 | 23 | router.HandleFunc("/health", handlers.HealthCheck).Methods("GET") |
22 | 24 |
|
23 | | - corsHandler := handlers.CORS( |
24 | | - handlers.AllowedOrigins([]string{"http://bulletcloud.com", "http://localhost:3000"}), // adicione seus domínios |
25 | | - handlers.AllowedMethods([]string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}), |
26 | | - handlers.AllowedHeaders([]string{"Content-Type", "Authorization"}), |
27 | | - ) |
28 | | - |
29 | | - handler := corsHandler(router) |
30 | | - |
31 | 25 | log.Println("Server starting on :8080") |
32 | | - log.Fatal(http.ListenAndServe(":8080", handler)) |
| 26 | + log.Fatal(http.ListenAndServe(":8080", router)) |
33 | 27 | } |
0 commit comments