♻️ Move web to sub-command

This commit is contained in:
Dan Jones 2023-03-24 13:03:21 -05:00
commit 213c9f6541
4 changed files with 45 additions and 31 deletions

28
main.go
View file

@ -1,37 +1,9 @@
package main
import (
"log"
"codeberg.org/danjones000/gopub/commands"
"codeberg.org/danjones000/gopub/config"
"github.com/gofiber/fiber/v2"
)
func main() {
commands.Execute()
}
type passReq struct {
Pass string `json:"pass"`
}
func mainOld() {
app := fiber.New()
conf := config.GetConfig()
app.Get("/", func(c *fiber.Ctx) error {
return c.JSON(&conf)
})
app.Post("/check_pass", func(c *fiber.Ctx) error {
req := new(passReq)
if err := c.BodyParser(req); err != nil {
panic(err)
}
return c.JSON(config.CheckPassword(req.Pass))
})
log.Fatal(app.Listen(":3000"))
}