Comments (3)
Sincerely thanks for explain me how this template work , you've show me a great point of view.
from fiber-go-template.
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template!
from fiber-go-template.
Hi,
I don't know why this option seems better to you, but I'll try to explain by example why I chose this way of organizing routes in the application. In the world of Go, it is a good thing to make fallback versions for REST API methods that are outdated but still in demand by users.
For this reason, to easily support two different versions of the API in one Fiber application, I will simply create another route file in which I set the next version of the API, like this:
// ./pkg/routes/public_routes_v2.go
// PublicRoutesV2 func for describe group of public routes for API v2.
func PublicRoutesV2(a *fiber.App) {
// Create routes group.
route := a.Group("/api/v2")
// Routes for GET method:
route.Get("/books", controllers.GetBooksV2) // <-- get list of all books for API v2
// ...
}
Note that all controllers for the new version of the API are also marked with the new names (with the ending V2
to make it easier to identify them).
And next, I will add this new routes group to the main.go
, like this:
// ./main.go
// ...
func main() {
// ...
// Routes.
// ...
routes.PublicRoutesV2(app) // <-- register a public routes with API v2 for app
// ...
}
As you can see, this way of organizing code in Fiber application allows you to keep a fallback version (for v1 users) and add new routes to make changes to the v2 API. And most importantly, this way is absolutely transparent for understanding and subsequent writing of unit tests because everything lies in its place: the description of routes and their challenge. 😉
If you are more convenient to use the option you gave in the example, then you are absolutely free to use it in your application! But I hope I've explained to you my point of view on this application template and the decisions made in it.
from fiber-go-template.
Related Issues (20)
- errSaveToRedis Causes Panic HOT 3
- `swag init` breaks `make critic` HOT 2
- zsh: killed cgapp create HOT 4
- flutter app? HOT 3
- pwa example please! HOT 3
- Running make test results in failure HOT 6
- go version error in Dockerfile HOT 1
- Dependabot can't resolve your Go dependency files HOT 1
- Swagger docs broken HOT 3
- Dependabot can't resolve your Go dependency files
- Wrong key for claims HOT 1
- Dependabot can't resolve your Go dependency files
- Dependabot can't resolve your Go dependency files
- Dependabot can't resolve your Go dependency files
- Dependabot can't resolve your Go dependency files
- Dependabot can't resolve your Go dependency files
- Error starting app HOT 2
- os.Interrupt does not respond to Ctrl+C after fiber get some requests HOT 3
- GetBooks returns empty HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fiber-go-template.