Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
68ef0fbf6b
|
9
serve.go
9
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
|
||||
|
||||
Reference in New Issue
Block a user