Created
October 19, 2016 19:37
-
-
Save thrawn01/299abf17ae62ed9fd19617bdab32820f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c *TagsAPIController) List(w http.ResponseWriter, r *http.Request, params map[string]string) (interface{}, error) { | |
val := NewValidator() | |
val.Param("limit").IsInt().Default("1000").Max(1000).Min(0) | |
val.Param("resolution").Allowed([]string{"month", "day", "year"}) | |
val.Param("page").Allowed([]string{"first", "last", "next", "prev"}).Default("first") | |
val.Param("prefix") | |
val.Param("tag") | |
params, err := val.Validate(r) | |
if err != nil { | |
return nil, err | |
} | |
limit := params.Int("limit") | |
if params.Set("prefix") { | |
// Do something | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment