Skip to content

Commit

Permalink
setup router now its own function, setup for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
GarbhanK committed May 23, 2024
1 parent 4d0a5dd commit c19a3df
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ func init() {
log.SetLevel(log.InfoLevel)
}

func main() {

func setupRouter() *gin.Engine {
r := gin.Default()

// dropping the GORM stuff for now, switching to Firebase
// models.ConnectDatabase()

r.GET("/", controllers.Root)
r.GET("/ping", controllers.Ping)
r.GET("/books", controllers.FindBooks)
r.POST("/books", controllers.CreateBook)
r.GET("/books/author/", controllers.FindAuthor)
r.GET("/books/title/", controllers.FindBook)
// r.PATCH("books/:id", controllers.UpdateBook)
r.DELETE("/books/", controllers.DeleteBook)
// r.PATCH("books/:id", controllers.UpdateBook)
return r
}

err := r.Run()
func main() {

r := setupRouter()

err := r.Run(":8080")
if err != nil {
return
}
Expand Down

0 comments on commit c19a3df

Please sign in to comment.