|
@@ -7,14 +7,24 @@ import (
|
|
|
)
|
|
|
|
|
|
func Redirect(c *gin.Context){
|
|
|
+ sid := c.Params.ByName("sid")
|
|
|
+ sq, err := shorturl.Shorter.GetSequence()
|
|
|
+ if err != nil {
|
|
|
+ c.JSON(200, gin.H{
|
|
|
+ "message": lib.String2Int(sid),
|
|
|
+ "sequence": lib.Int2String(sq),
|
|
|
+ "sequence_id": sq,
|
|
|
+ "error": err,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ c.JSON(200, gin.H{
|
|
|
+ "message": lib.String2Int(sid),
|
|
|
+ "sequence": lib.Int2String(sq),
|
|
|
+ "sequence_id": sq,
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
func Short(c *gin.Context){
|
|
|
- sid := c.Params.ByName("sid")
|
|
|
- sq, _ := shorturl.Shorter.GetSequence()
|
|
|
- c.JSON(200, gin.H{
|
|
|
- "message": lib.String2Int(sid),
|
|
|
- "sequence": lib.Int2String(sq),
|
|
|
- "sequence_id": sq,
|
|
|
- })
|
|
|
+
|
|
|
}
|