Skip to content

Commit

Permalink
chore: Update index template with lazy loading for images
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmedhossamdev committed Jul 8, 2024
1 parent fe53dd2 commit 2144a1e
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions routes/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package routes
import (
"Ahmedhossamdev/search-engine/views"
"fmt"
"time"

"github.com/a-h/templ"
"github.com/gofiber/fiber/v2"
Expand All @@ -26,22 +25,40 @@ type loginForm struct {
Password string `form:"password"`
}

type settingsForm struct {
Amount int `form:"amount"`
SearchOn bool `form:"searchOn"`
AddNew bool `form:"addNew"`
}



func SetRoutes(app *fiber.App) {
app.Get("/", func(c *fiber.Ctx) error {
return render(c, views.Home())
})


app.Post("/", func(c *fiber.Ctx) error {
input := settingsForm{}
if err := c.BodyParser(&input); err != nil {
return c.SendString("<h1>Error: Something went wrong.. Please try again</h1>")
}

fmt.Println(input);
return c.SendStatus(200)
});


app.Get("login", func(c *fiber.Ctx) error {
return render(c, views.Login())
})

app.Post("login", func(c *fiber.Ctx) error {
time.Sleep(2 * time.Second)
input := loginForm{}
if err := c.BodyParser(&input); err != nil {
return c.SendString("<h1>Error: Something went wrong.. Please try again</h1>")
}
fmt.Println(input)
return c.SendStatus(200)
});
}

0 comments on commit 2144a1e

Please sign in to comment.