-
Notifications
You must be signed in to change notification settings - Fork 0
/
method.go
173 lines (143 loc) · 4.58 KB
/
method.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// Code generated by goagen v1.3.1, DO NOT EDIT.
//
// API "goa simple sample": method Resource Client
//
// Command:
// $ goagen
// --design=github.com/pei0804/goa-simple-sample/design
// --out=$(GOPATH)/src/github.com/pei0804/goa-simple-sample
// --version=v1.3.1
package client
import (
"context"
"fmt"
"net/http"
"net/url"
"strconv"
)
// EtcMethodPath computes a request path to the etc action of method.
func EtcMethodPath(id int, type_ int) string {
param0 := strconv.Itoa(id)
param1 := strconv.Itoa(type_)
return fmt.Sprintf("/api/v1/method/users/%s/follow/%s", param0, param1)
}
// ちょっと特殊ケース
func (c *Client) EtcMethod(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewEtcMethodRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewEtcMethodRequest create the request corresponding to the etc action endpoint of the method resource.
func (c *Client) NewEtcMethodRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "https"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// FollowMethodPath computes a request path to the follow action of method.
func FollowMethodPath() string {
return fmt.Sprintf("/api/v1/method/users/follow")
}
// FollowMethodPath2 computes a request path to the follow action of method.
func FollowMethodPath2() string {
return fmt.Sprintf("/api/v1/method/users/follow")
}
// フォロー操作
func (c *Client) FollowMethod(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewFollowMethodRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewFollowMethodRequest create the request corresponding to the follow action endpoint of the method resource.
func (c *Client) NewFollowMethodRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "https"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequest("PUT", u.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// ListMethodPath computes a request path to the list action of method.
func ListMethodPath() string {
return fmt.Sprintf("/api/v1/method/list")
}
// ListMethodPath2 computes a request path to the list action of method.
func ListMethodPath2() string {
return fmt.Sprintf("/api/v1/method/list/new")
}
// ListMethodPath3 computes a request path to the list action of method.
func ListMethodPath3() string {
return fmt.Sprintf("/api/v1/method/list/topic")
}
// リストを返す
func (c *Client) ListMethod(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewListMethodRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewListMethodRequest create the request corresponding to the list action endpoint of the method resource.
func (c *Client) NewListMethodRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "https"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// MethodMethodPath computes a request path to the method action of method.
func MethodMethodPath() string {
return fmt.Sprintf("/api/v1/method/get")
}
// MethodMethodPath2 computes a request path to the method action of method.
func MethodMethodPath2() string {
return fmt.Sprintf("/api/v1/method/post")
}
// MethodMethodPath3 computes a request path to the method action of method.
func MethodMethodPath3() string {
return fmt.Sprintf("/api/v1/method/delete")
}
// MethodMethodPath4 computes a request path to the method action of method.
func MethodMethodPath4() string {
return fmt.Sprintf("/api/v1/method/put")
}
// HTTPメソッド
func (c *Client) MethodMethod(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewMethodMethodRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewMethodMethodRequest create the request corresponding to the method action endpoint of the method resource.
func (c *Client) NewMethodMethodRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "https"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}