fixed bug
This commit is contained in:
parent
62e7600a22
commit
a6687225b8
13
merp.go
13
merp.go
|
@ -5,6 +5,7 @@ import "net/http"
|
|||
import "regexp"
|
||||
import "time"
|
||||
|
||||
import "github.com/astaxie/beego/orm"
|
||||
import "github.com/gin-gonic/gin"
|
||||
import "github.com/google/uuid"
|
||||
import "github.com/rs/zerolog/log"
|
||||
|
@ -30,10 +31,12 @@ func decodeJSON(in []byte) interface{} {
|
|||
|
||||
func getLatestMerps() gin.HandlerFunc {
|
||||
ThingRegex := thingRegex()
|
||||
orm := models.GetOrmObject()
|
||||
o := models.GetOrmObject()
|
||||
|
||||
h := func(c *gin.Context) {
|
||||
|
||||
thing := c.Param("thing")
|
||||
|
||||
if thing != "" {
|
||||
if ThingRegex.MatchString(thing) == false {
|
||||
c.JSON(http.StatusPreconditionFailed, gin.H{
|
||||
|
@ -43,9 +46,13 @@ func getLatestMerps() gin.HandlerFunc {
|
|||
})
|
||||
return
|
||||
}
|
||||
qs := orm.QueryTable("merp").Filter("thing", thing).OrderBy("-created").Limit(50)
|
||||
}
|
||||
|
||||
var qs orm.QuerySeter
|
||||
if thing == "" {
|
||||
qs = o.QueryTable("merp").OrderBy("-created").Limit(50)
|
||||
} else {
|
||||
qs := orm.QueryTable("merp").OrderBy("-created").Limit(50)
|
||||
qs = o.QueryTable("merp").Filter("thing", thing).OrderBy("-created").Limit(50)
|
||||
}
|
||||
|
||||
var merps []*models.Merp
|
||||
|
|
Loading…
Reference in New Issue