@@ -17,13 +17,13 @@ const (
17
17
defaultPartnerType = "Associates"
18
18
)
19
19
20
- //Query interface for Client type
20
+ // Query interface for Client type
21
21
type Query interface {
22
22
Operation () Operation
23
23
Payload () ([]byte , error )
24
24
}
25
25
26
- //Client interface
26
+ // Client interface
27
27
type Client interface {
28
28
Marketplace () string
29
29
PartnerTag () string
@@ -32,7 +32,7 @@ type Client interface {
32
32
RequestContext (context.Context , Query ) ([]byte , error )
33
33
}
34
34
35
- //client is http.Client for Aozora API Server
35
+ // client is http.Client for Aozora API Server
36
36
type client struct {
37
37
server * Server
38
38
client fetch.Client
@@ -41,27 +41,27 @@ type client struct {
41
41
secretKey string
42
42
}
43
43
44
- //Marketplace returns name of Marketplace parameter for PA-API v5
44
+ // Marketplace returns name of Marketplace parameter for PA-API v5
45
45
func (c * client ) Marketplace () string {
46
46
return c .server .Marketplace ()
47
47
}
48
48
49
- //PartnerTag returns PartnerTag parameter for PA-API v5
49
+ // PartnerTag returns PartnerTag parameter for PA-API v5
50
50
func (c * client ) PartnerTag () string {
51
51
return c .partnerTag
52
52
}
53
53
54
- //PartnerType returns PartnerType parameter for PA-API v5
54
+ // PartnerType returns PartnerType parameter for PA-API v5
55
55
func (c * client ) PartnerType () string {
56
56
return defaultPartnerType
57
57
}
58
58
59
- //Request method returns response data (JSON format) by PA-APIv5.
59
+ // Request method returns response data (JSON format) by PA-APIv5.
60
60
func (c * client ) Request (q Query ) ([]byte , error ) {
61
61
return c .RequestContext (context .Background (), q )
62
62
}
63
63
64
- //RequestContext method returns response data (JSON format) by PA-APIv5. (with context.Context)
64
+ // RequestContext method returns response data (JSON format) by PA-APIv5. (with context.Context)
65
65
func (c * client ) RequestContext (ctx context.Context , q Query ) ([]byte , error ) {
66
66
payload , err := q .Payload ()
67
67
if err != nil {
@@ -79,10 +79,10 @@ func (c *client) post(ctx context.Context, cmd Operation, payload []byte) ([]byt
79
79
u := c .server .URL (cmd .Path ())
80
80
hds := newHeaders (c .server , cmd , dt )
81
81
sig := c .signiture (c .signedString (hds , payload ), hds )
82
- resp , err := c .client .Post (
82
+ resp , err := c .client .PostWithContext (
83
+ ctx ,
83
84
u ,
84
85
bytes .NewReader (payload ),
85
- fetch .WithContext (ctx ),
86
86
fetch .WithRequestHeaderSet ("Accept" , c .server .Accept ()),
87
87
fetch .WithRequestHeaderSet ("Accept-Language" , c .server .AcceptLanguage ()),
88
88
fetch .WithRequestHeaderSet ("Content-Type" , c .server .ContentType ()),
0 commit comments