This commit is contained in:
Tijl 2025-08-06 20:28:19 +02:00
parent 17a9c5835e
commit 98a83549f0
Signed by: tijl
GPG Key ID: DAE24BFCD722F053

View File

@ -22,13 +22,16 @@ func (s *Server) Admin() *fiber.App {
})
a.Post("/shorten", func(c *fiber.Ctx) error {
longUrl := string(c.Body())
shortUrl := c.Query("s")
if shortUrl == "" {
shortUrl = s.serverGen.NextID()
}
longUrl := string(c.Body())
return s.storage.Put(shortUrl, longUrl)
err := s.storage.Put(shortUrl, longUrl)
if err != nil {
return err
}
return c.SendString(shortUrl)
})
return a