trying to log requests
parent
0948f2c5f5
commit
3329a56e38
27
main.go
27
main.go
|
|
@ -25,18 +25,6 @@ func main() {
|
|||
log.Println("Starting API", globals.API_VERSION)
|
||||
log.Println("OS:", os.Getenv("OS"))
|
||||
|
||||
app := fiber.New(fiber.Config{
|
||||
StrictRouting: false,
|
||||
DisableStartupMessage: true,
|
||||
})
|
||||
|
||||
app.Use(cors.New(cors.Config{
|
||||
AllowCredentials: true,
|
||||
AllowOrigins: "http://*, https://*",
|
||||
AllowHeaders: "Origin, Content-Type, User-Agent, Connection, User-Agent, Accept, Authorization, Access-Control-Allow-Origin",
|
||||
AllowMethods: "GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS",
|
||||
}))
|
||||
|
||||
file, err := os.OpenFile("./api-homolog.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -45,8 +33,21 @@ func main() {
|
|||
|
||||
defer file.Close()
|
||||
|
||||
app := fiber.New(fiber.Config{
|
||||
StrictRouting: false,
|
||||
DisableStartupMessage: true,
|
||||
})
|
||||
|
||||
app.Use(logger.New(logger.Config{
|
||||
Output: file,
|
||||
// Output: file,
|
||||
Format: "[${ip}]:${port} ${status} - ${method} ${path}\n",
|
||||
}))
|
||||
|
||||
app.Use(cors.New(cors.Config{
|
||||
AllowCredentials: true,
|
||||
AllowOrigins: "http://*, https://*",
|
||||
AllowHeaders: "Origin, Content-Type, Accept, Authorization, Access-Control-Allow-Origin",
|
||||
AllowMethods: "GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS",
|
||||
}))
|
||||
|
||||
if err := database.ConnectDB(); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue