-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
37 lines (27 loc) · 1.01 KB
/
main.go
File metadata and controls
37 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"github.com/gin-gonic/gin"
"github.com/gustonecrush/api-marvel-database/controllers/authcontroller"
"github.com/gustonecrush/api-marvel-database/controllers/herocontroller"
"github.com/gustonecrush/api-marvel-database/models"
)
func main() {
r := gin.Default()
models.ConnectDatabase()
// endpoints hero
r.GET("/api/heroes", herocontroller.Index)
r.GET("/api/heroes/:id", herocontroller.Show)
r.POST("/api/heroes", herocontroller.Create)
r.PUT("/api/heroes/:id", herocontroller.Update)
r.DELETE("/api/heroes", herocontroller.Delete)
// endpoints auth
r.POST("/api/register", authcontroller.Register)
r.POST("/api/login", authcontroller.Login)
r.GET("/api/logout", authcontroller.Logout)
// r := mux.NewRouter()
// r.HandleFunc("/api/login", authcontroller.Login).Methods("POST")
// r.HandleFunc("/api/register", authcontroller.Register).Methods("POST")
// r.HandleFunc("/api/logout", authcontroller.Logout).Methods("POST")
// log.Fatal(http.ListenAndServe(":8080", r))
r.Run()
}