switch to go vendoring
This commit is contained in:
+95
@@ -0,0 +1,95 @@
|
||||
# icap-client
|
||||
|
||||
[](LICENSE)
|
||||
[](https://github.com/egirna/icap-client/releases)
|
||||
[](https://godoc.org/github.com/egirna/icap-client)
|
||||
|
||||
|
||||
Talk to the ICAP servers using probably the first ICAP client package in GO!
|
||||
|
||||
### Installing
|
||||
```console
|
||||
go get -u github.com/egirna/icap-client
|
||||
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
**Import The Package**
|
||||
|
||||
```go
|
||||
import ic "github.com/egirna/icap-client"
|
||||
|
||||
```
|
||||
|
||||
**Making a simple RESPMOD call**
|
||||
|
||||
```go
|
||||
|
||||
req, err := ic.NewRequest(ic.MethodRESPMOD, "icap://<host>:<port>/<path>", httpReq, httpResp)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
client := &ic.Client{
|
||||
Timeout: 5 * time.Second,
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
**Note**: ``httpReq`` & ``httpResp`` here are ``*http.Response`` & ``*http.Request`` respectively
|
||||
|
||||
**Setting preview obtained from OPTIONS call**
|
||||
|
||||
```go
|
||||
|
||||
optReq, err := ic.NewRequest(ic.MethodOPTIONS, "icap://<host>:<port>/<path>", nil, nil)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
|
||||
client := &ic.Client{
|
||||
Timeout: 5 * time.Second,
|
||||
}
|
||||
|
||||
req.SetPreview(optReq.PreviewBytes)
|
||||
|
||||
// do something with req(ICAP *Request)
|
||||
|
||||
```
|
||||
|
||||
**DEBUG Mode**
|
||||
|
||||
Turn on debug mode to inspect detailed & verbose logs to debug your code during development
|
||||
|
||||
```go
|
||||
ic.SetDebugMode(true)
|
||||
|
||||
```
|
||||
|
||||
By default the icap-client will dump the debugging logs to the standard output(stdout), but you can always add your custom writer
|
||||
|
||||
```go
|
||||
f, _ := os.OpenFile("logs.txt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
||||
ic.SetDebugOutput(f)
|
||||
```
|
||||
|
||||
For more details, see the [docs](https://godoc.org/github.com/egirna/icap-client) and [examples](examples/).
|
||||
|
||||
|
||||
### Contributing
|
||||
|
||||
This package is still WIP, so totally open to suggestions. See the contributions guide [here](CONTRIBUTING.md).
|
||||
|
||||
### License
|
||||
|
||||
**icap-client** is licensed under the [Apache License](LICENSE).
|
||||
Reference in New Issue
Block a user