-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi_v2p1.go
33 lines (26 loc) · 1.03 KB
/
api_v2p1.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
package seafile
import (
"bytes"
"io"
"net/http"
"net/url"
)
func (cli *Client) apiRequestV2p1(method, uri string, header http.Header, body io.Reader) (*http.Response, error) {
return cli.requestApi("/api/v2.1", method, uri, header, body)
}
func (cli *Client) apiGET(uri string) (*http.Response, error) {
return cli.apiRequestV2p1("GET", uri, nil, nil)
}
func (cli *Client) apiPOSTForm(uri string, form url.Values) (*http.Response, error) {
header := http.Header{"Content-Type": {"application/x-www-form-urlencoded"}}
return cli.apiRequestV2p1("POST", uri, header, bytes.NewBufferString(form.Encode()))
}
func (cli *Client) apiPOST(uri string, header http.Header, body io.Reader) (*http.Response, error) {
return cli.apiRequestV2p1("POST", uri, header, body)
}
func (cli *Client) apiPUT(uri string, header http.Header, body io.Reader) (*http.Response, error) {
return cli.apiRequestV2p1("PUT", uri, header, body)
}
func (cli *Client) apiDELETE(uri string) (*http.Response, error) {
return cli.apiRequestV2p1("DELETE", uri, nil, nil)
}