Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/165.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
http mock server: Added glob template helper function for iterating over multiple files.
```
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ When using [Go templates](https://golang.org/pkg/text/template/) as part of the
- `env KEY`: function that returns the KEY from environment.
- `sum A B`: function that returns the sum of numbers A and B (only for integers).
- `file PATH`: function that returns the contents of the file at PATH.
- `glob PATTERN`: function that returns the names of all files matching glob PATTERN (see [filepath.Match](https://pkg.go.dev/path/filepath#Match) for syntax).
- `.req_num`: variable containing the current request number, auto incremented after every request for the rule.
- `.request.vars`: map containing the variables received in the request (both query and form).
- `.request.url`: the url object. Can be used as per [the Go URL documentation.](https://golang.org/pkg/net/url/#URL)
Expand Down
2 changes: 2 additions & 0 deletions internal/httpserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"errors"
"os"
"path/filepath"
"strings"
"text/template"

Expand Down Expand Up @@ -51,6 +52,7 @@ func (t *tpl) Unpack(in string) error {
"hostname": hostname,
"sum": sum,
"file": file,
"glob": filepath.Glob,
"minify_json": minify,
}).
Parse(in)
Expand Down
Loading