fix code formatting
All checks were successful
Build and publish the docker image / build (push) Successful in 1m2s
All checks were successful
Build and publish the docker image / build (push) Successful in 1m2s
Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
62
main.go
62
main.go
@ -12,42 +12,42 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
extractor *extract.Extractor
|
||||
err error
|
||||
)
|
||||
var (
|
||||
extractor *extract.Extractor
|
||||
err error
|
||||
)
|
||||
|
||||
// configure logger
|
||||
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
|
||||
// configure logger
|
||||
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
|
||||
|
||||
if extractor, err = extract.New(); err != nil {
|
||||
log.Printf("failed to create an extractor: %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
if extractor, err = extract.New(); err != nil {
|
||||
log.Printf("failed to create an extractor: %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
engine := html.New("./views", ".html")
|
||||
app := fiber.New(fiber.Config{
|
||||
AppName: "tren",
|
||||
DisableStartupMessage: true,
|
||||
ServerHeader: "",
|
||||
Views: engine,
|
||||
})
|
||||
engine := html.New("./views", ".html")
|
||||
app := fiber.New(fiber.Config{
|
||||
AppName: "tren",
|
||||
DisableStartupMessage: true,
|
||||
ServerHeader: "",
|
||||
Views: engine,
|
||||
})
|
||||
|
||||
app.Static("/", "./static")
|
||||
app.Use("*", func(c *fiber.Ctx) error {
|
||||
c.Locals("extractor", extractor)
|
||||
return c.Next()
|
||||
})
|
||||
app.Static("/", "./static")
|
||||
app.Use("*", func(c *fiber.Ctx) error {
|
||||
c.Locals("extractor", extractor)
|
||||
return c.Next()
|
||||
})
|
||||
|
||||
// routes
|
||||
app.Get("/", routes.GET_index)
|
||||
app.Post("/translate", routes.POST_translate)
|
||||
// routes
|
||||
app.Get("/", routes.GET_index)
|
||||
app.Post("/translate", routes.POST_translate)
|
||||
|
||||
// all the other routes redirect to index
|
||||
app.All("*", func(c *fiber.Ctx) error {
|
||||
return util.RenderError(c, 404)
|
||||
})
|
||||
// all the other routes redirect to index
|
||||
app.All("*", func(c *fiber.Ctx) error {
|
||||
return util.RenderError(c, 404)
|
||||
})
|
||||
|
||||
log.Printf("starting the web application on port 8080")
|
||||
log.Fatal(app.Listen(":8080"))
|
||||
log.Printf("starting the web application on port 8080")
|
||||
log.Fatal(app.Listen(":8080"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user