Skip to content

Repository files navigation

icap-client

LicenseProject statusGoDoc

Talk to the ICAP servers using probably the first ICAP client package in GO!

Installing

go get -u github.com/egirna/icap-client

Usage

Import The Package

import ic "github.com/egirna/icap-client"

Making a simple RESPMOD call

req, err:=ic.NewRequest(ic.MethodRESPMOD, "icap://<host>:<port>/<path>", httpReq, httpResp)
iferr!=nil {
log.Fatal(err)
}
client:=&ic.Client{
Timeout: 5*time.Second,
}
resp, err:=client.Do(req)
iferr!=nil {
log.Fatal(err)
}

Note: httpReq & httpResp here are *http.Response & *http.Request respectively

Setting preview obtained from OPTIONS call

optReq, err:=ic.NewRequest(ic.MethodOPTIONS, "icap://<host>:<port>/<path>", nil, nil)
iferr!=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

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

f, _:=os.OpenFile("logs.txt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
ic.SetDebugOutput(f)

For more details, see the docs and examples.

Contributing

This package is still WIP, so totally open to suggestions. See the contributions guide here.

License

icap-client is licensed under the Apache License.

About

An ICAP client package for GO!

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages