MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / App

Method App

api/pkg/di/container.go:169–209  ·  view source on GitHub ↗

App creates a new instance of fiber.App

()

Source from the content-addressed store, hash-verified

167
168// App creates a new instance of fiber.App
169func (container *Container) App() (app *fiber.App) {
170 if container.app != nil {
171 return container.app
172 }
173
174 container.logger.Debug(fmt.Sprintf("creating %T", app))
175
176 app = fiber.New()
177
178 // Health check endpoint registered before middleware for reliable Docker health checks
179 app.Get("/health", func(c fiber.Ctx) error {
180 return c.SendStatus(fiber.StatusOK)
181 })
182
183 app.Use(compress.New(compress.Config{
184 Level: compress.LevelBestCompression,
185 }))
186
187 if os.Getenv("USE_HTTP_LOGGER") == "true" {
188 app.Use(fiberLogger.New())
189 }
190
191 app.Use(otelfiber.Middleware())
192 app.Use(
193 cors.New(
194 cors.Config{
195 AllowOrigins: splitCommaEnv("CORS_ALLOW_ORIGINS", "*"),
196 AllowHeaders: splitCommaEnv("CORS_ALLOW_HEADERS", "*"),
197 AllowMethods: splitCommaEnv("CORS_ALLOW_METHODS", "GET,POST,PUT,DELETE,OPTIONS"),
198 AllowCredentials: false,
199 ExposeHeaders: splitCommaEnv("CORS_EXPOSE_HEADERS", "*"),
200 },
201 ),
202 )
203 app.Use(middlewares.HTTPRequestLogger(container.Tracer(), container.Logger()))
204 app.Use(middlewares.BearerAuth(container.Logger(), container.Tracer(), container.FirebaseAuthClient()))
205 app.Use(middlewares.APIKeyAuth(container.Logger(), container.Tracer(), container.UserRepository()))
206
207 container.app = app
208 return app
209}
210
211// BearerAPIKeyMiddleware creates a new instance of middlewares.BearerAPIKeyAuth
212func (container *Container) BearerAPIKeyMiddleware() fiber.Handler {

Callers 15

mainFunction · 0.95
RegisterDiscordRoutesMethod · 0.95
RegisterMessageRoutesMethod · 0.95
RegisterBillingRoutesMethod · 0.95
RegisterWebhookRoutesMethod · 0.95

Calls 7

TracerMethod · 0.95
LoggerMethod · 0.95
FirebaseAuthClientMethod · 0.95
UserRepositoryMethod · 0.95
splitCommaEnvFunction · 0.85
DebugMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected