1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-07-17 01:32:22 +02:00

Update README.md

This commit is contained in:
Tim Voronov
2018-12-10 14:09:25 -05:00
committed by GitHub
parent a219e776ad
commit 0ec1f86e88

View File

@ -413,3 +413,44 @@ func main() {
comp.RegisterFunctions(strings.NewLib())
}
```
## Proxy
By default, Ferret does not use any proxies. But you can pass an address of a proxy server you want to use.
#### CLI
```sh
ferret --proxy=http://localhost:8888 my-query.fql
```
#### Code
```go
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/MontFerret/ferret/pkg/compiler"
"github.com/MontFerret/ferret/pkg/html"
)
func run(q string) ([]byte, error) {
proxy := "http://localhost:8888"
comp := compiler.New()
program := comp.MustCompile(q)
// create a root context
ctx := context.Background()
// we inform each driver what proxy to use
ctx = html.WithDynamicDriver(ctx, dynamic.WithProxy(proxy))
ctx = html.WithStaticDriver(ctx, statuc.WithProxy(proxy))
return program.Run(ctx)
}
```