-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🤔 How can I structure my routes into seperate files? #270
Comments
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you want to chat with us or need help, join us on our Discord server: https://gofiber.io/discord |
Hey @monzarrugh If I understood you, I suggest you use a design pattern in your project, I am using currently https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html |
Structure routes into seperate files may caused routes conflict 🤔 |
@monzarrugh, does this help https://github.com/gofiber/boilerplate or https://blog.sallai.me/rest-api-with-fiber/? |
Yes I'd like to handle a group requests in a separate file |
@monzarrugh you could pass // ./main.go
package main
import (
"./routes"
"github.com/gofiber/fiber"
)
func main() {
app := fiber.New()
routes.Register(app)
//app.Get("/admin", handlerAdmin)
//app.Post("/register", handlerRegister)
//app.Post("/login", handlerLogin)
app.Listen(3000)
} // ./routes/api.go
package routes
import (
"github.com/gofiber/fiber"
)
func Register(app *fiber.App) {
app.Get("/admin", handlerAdmin)
app.Post("/register", handlerRegister)
app.Post("/login", handlerLogin)
} |
Right now all of my routes are in the main function.
What is the correct way to structure my application so that I can separate routes into multiple files the same way as with express?
I want to handle the GET, POST etc. of each route in a separate file for that route
The text was updated successfully, but these errors were encountered: