nastya / icap-client

An ICAP client package for GO!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

icap-client

License Project status GoDoc

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)

  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

  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

  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!

License:Apache License 2.0


Languages

Language:Go 100.0%