Skip to content

Commit 537c368

Browse files
committed
add default method
1 parent e4d4845 commit 537c368

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

model/curl_model.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,17 @@ func (c *CURL) GetMethod() (method string) {
186186
keys := []string{"-X", "--request"}
187187
value := c.getDataValue(keys)
188188
if len(value) <= 0 {
189-
return
189+
return c.defaultMethod()
190190
}
191191
method = strings.ToUpper(value[0])
192192
if helper.InArrayStr(method, []string{"GET", "POST", "PUT", "DELETE"}) {
193193
return method
194194
}
195+
return c.defaultMethod()
196+
}
197+
198+
// defaultMethod 获取默认方法
199+
func (c *CURL) defaultMethod() (method string) {
195200
method = "GET"
196201
body := c.GetBody()
197202
if len(body) > 0 {
@@ -254,3 +259,4 @@ func (c *CURL) getPostForm() (body string) {
254259
return
255260
}
256261

262+

0 commit comments

Comments
 (0)