Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
appModule := &fiberdi.Module{}
New creates a new Fiber named instance.
app := fiberdi.New(appModule)
You can pass optional configuration options by passing a Config struct:
app := fiber.New(appModule, fiber.Config{
Prefork: true,
ServerHeader: "Fiber",
})
ATTENTION: DisableStartupMessage is true and cannot be changed
Types ¶
type IController ¶
type Module ¶
type Module struct {
// Controller needs function Routes
//
// type YourController struct {}
//
// func (controller YourController) Routes(app *fiber.App) *fiber.App {
// app.Get("/", DoSomething)
// return app
// }
//
// appModule := &fiberdi.Module{
// Controllers: []fiberdi.IController{
// &YourController{},
// },
// }
Controllers []IController
// Injectables persist all your dependencies
//
// type YourService struct {}
//
// func (controller YourService) DoSomething(ctx *fiber.Ctx) error {
// return ctx.JSON("OK")
// }
//
// type YourController struct {
// YourService *YourService
// }
//
// func (controller YourController) Routes(app *fiber.App) *fiber.App {
// app.Get("/", controller.YourService.DoSomething)
// return app
// }
//
// appModule := &fiberdi.Module{
// Controllers: []fiberdi.IController{
// &YourController{},
// },
// Injectables: []interface{}{
// &YourService{},
// },
// }
Injectables []interface{}
// You can create submodules
//
// type CatService struct {}
//
// func (controller CatService) DoSomething(ctx *fiber.Ctx) error {
// return ctx.JSON("Cat")
// }
//
// type CatController struct {
// CatService *CatService
// }
//
// func (controller CatController) Routes(app *fiber.App) *fiber.App {
// app.Get("/", controller.CatService.DoSomething)
// return app
// }
//
// catModule := &fiberdi.Module{
// Controllers: []fiberdi.IController{
// &CatController{},
// },
// Injectables: []interface{}{
// &CatService{},
// },
// }
//
// appModule := &fiberdi.Module{
// Modules: []fiberdi.IModule{
// catModule,
// },
// }
Modules []IModule
}
Module manage your dependencies and routes
appModule := &fiberdi.Module{}
Click to show internal directories.
Click to hide internal directories.