-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathdoc.go
73 lines (73 loc) · 1.77 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//Package icapclient is a client package for the ICAP protocol
//
// Here is a basic example:
// package main
//
// import (
// "fmt"
// "logging"
// "net/http"
// "time"
//
// ic "github.com/egirna/icap-client"
// )
//
// func main() {
// /* preparing the http request required for the RESPMOD */
// httpReq, err := http.NewRequest(http.MethodGet, "http://localhost:8000/sample.pdf", nil)
//
// if err != nil {
// logging.Fatal(err)
// }
//
// /* making the http client & making the request call to get the response needed for the icap RESPMOD call */
// httpClient := &http.Client{}
//
// httpResp, err := httpClient.Do(httpReq)
//
// if err != nil {
// logging.Fatal(err)
// }
//
// /* making a icap request with OPTIONS method */
// optReq, err := ic.NewRequest(ic.MethodOPTIONS, "icap://127.0.0.1:1344/respmod", nil, nil)
//
// if err != nil {
// logging.Fatal(err)
// return
// }
//
// /* making the icap client responsible for making the requests */
// client := &ic.Client{
// Timeout: 5 * time.Second,
// }
//
// /* making the OPTIONS request call */
// optResp, err := client.Do(optReq)
//
// if err != nil {
// logging.Fatal(err)
// return
// }
//
// /* making a icap request with RESPMOD method */
// req, err := ic.NewRequest(ic.MethodRESPMOD, "icap://127.0.0.1:1344/respmod", httpReq, httpResp)
//
// if err != nil {
// logging.Fatal(err)
// }
//
// req.SetPreview(optResp.PreviewBytes) // setting the preview bytes obtained from the OPTIONS call
//
// /* making the RESPMOD request call */
// resp, err := client.Do(req)
//
// if err != nil {
// logging.Fatal(err)
// }
//
// fmt.Println(resp.StatusCode)
//
// }
// See https://github.com/egirna/icap-client/examples.
package icapclient