//3456789112345676892123456789312345678941234567895123456789612345678971234567898 package main import "net/http" import "regexp" import "time" import "github.com/rs/zerolog/log" import "github.com/gin-gonic/gin" /* func GetLatestMerps() gin.HandlerFunc { } func GetLatestMerp() gin.HandlerFunc { } */ func HandleNewMerp() gin.HandlerFunc { THING_REGEX, e := regexp.Compile(`^[a-zA-Z0-9\_\-]+$`) if e != nil { panic(e) } h := func(c *gin.Context) { thing := c.Param("thing") if THING_REGEX.MatchString(thing) == false { log.Info().Msgf("%s didnt match", thing) c.JSON(http.StatusPreconditionFailed, gin.H{ "this": "failed", }) return } log.Info().Msgf("%s matched", thing) //web.Get(`/merp/for/([A-Za-z0-9\-\_\.]+)`, merpHandler) content := gin.H{} for k, v := range c.Request.URL.Query() { content[k] = v[0] } c.JSON(http.StatusOK, gin.H{ "this": "succeeded", "by": "merping", "the": "merp", "with": gin.H{ "thing": thing, "created": time.Now().UTC().Format(time.RFC3339), "content": content, }, }) } return h }