From 68ef0fbf6ba1f0ef2d389689331d1aa681b698fe Mon Sep 17 00:00:00 2001 From: tijl Date: Wed, 6 Aug 2025 20:28:19 +0200 Subject: [PATCH] up --- serve.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/serve.go b/serve.go index 95e8f13..733b445 100644 --- a/serve.go +++ b/serve.go @@ -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