https://github.com/benpate/exp-builder
https://github.com/benpate/exp-builder
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/benpate/exp-builder
- Owner: benpate
- License: apache-2.0
- Created: 2022-06-20T23:46:21.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-14T22:08:10.000Z (5 months ago)
- Last Synced: 2025-03-19T01:11:22.081Z (4 months ago)
- Language: Go
- Size: 50.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Expression Builder 🔨
[](http://pkg.go.dev/github.com/benpate/exp-builder)
[](https://github.com/benpate/exp-builder/releases)
[](https://github.com/benpate/exp-builder/actions/workflows/go.yml)
[](https://goreportcard.com/report/github.com/benpate/exp-builder)
[](https://codecov.io/gh/benpate/exp-builder)## Safe queries from URL query strings
Expression Builder works with the [exp expression library](https://github.com/benpate/exp) to define templates that are safely populated with data from a URL query string. More documentation to come.
```go
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...
}
```## Pull Requests Welcome
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! 🔨