Expression Builder works with the exp expression library to define templates that are safely populated with data from a URL query string. More documentation to come.
func Handler(r *http.Request, w http.ResponseWriter) {
// Define the URL arguments you want to allow and their types
b := NewBuilder().
String("firstName").
String("lastName").
Int("publishDate").
Bool("isPublished")
// Create a usable expression from the URL query string
expression := b.Evaluate(r.URL.Query())
// Next, safely pass it into the database, or something...
}
This library is a work in progress, and will benefit from your experience reports, use cases, and contributions. If you have an idea for making this library better, send in a pull request. We're all in this together! ๐จ