125 lines
2.7 KiB
Go
125 lines
2.7 KiB
Go
// Package curl ...
|
|
//
|
|
// Author: go_developer@163.com<白茶清欢>
|
|
//
|
|
// Description:
|
|
//
|
|
// File: request.go
|
|
//
|
|
// Version: 1.0.0
|
|
//
|
|
// Date: 2022/05/01 21:25:03
|
|
package curl
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
// Request 发送请求
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2022/05/01 21:26:02
|
|
func Request(apiConfig *ApiRequestConfig, param map[string]interface{}) *ApiResponse {
|
|
apiConfig.Method = strings.ToUpper(apiConfig.Method)
|
|
switch apiConfig.Method {
|
|
case http.MethodGet:
|
|
return GET(apiConfig, param)
|
|
case http.MethodPost:
|
|
return POST(apiConfig, param)
|
|
case http.MethodPut:
|
|
return PUT(apiConfig, param)
|
|
case http.MethodDelete:
|
|
return DELETE(apiConfig, param)
|
|
case http.MethodConnect:
|
|
return Connect(apiConfig, param)
|
|
case http.MethodOptions:
|
|
return OPTION(apiConfig, param)
|
|
case http.MethodTrace:
|
|
return Trace(apiConfig, param)
|
|
case http.MethodPatch:
|
|
return Patch(apiConfig, param)
|
|
default:
|
|
return &ApiResponse{
|
|
RequestConfig: apiConfig,
|
|
HttpCode: 0,
|
|
Body: nil,
|
|
BodyType: "",
|
|
Exception: NewException(RequestMethodNotSupport, map[string]string{"method": apiConfig.Method}),
|
|
}
|
|
}
|
|
}
|
|
|
|
// GET ...
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date: 2022/05/01 21:29:09
|
|
func GET(apiConfig *ApiRequestConfig, param map[string]interface{}) *ApiResponse {
|
|
return nil
|
|
}
|
|
|
|
// POST post请求
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2022/05/01 21:31:36
|
|
func POST(apiConfig *ApiRequestConfig, param map[string]interface{}) *ApiResponse {
|
|
return nil
|
|
}
|
|
|
|
// PUT put请求
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2022/05/01 21:31:52
|
|
func PUT(apiConfig *ApiRequestConfig, param map[string]interface{}) *ApiResponse {
|
|
return nil
|
|
}
|
|
|
|
// DELETE delete请求
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2022/05/01 21:32:08
|
|
func DELETE(apiConfig *ApiRequestConfig, param map[string]interface{}) *ApiResponse {
|
|
return nil
|
|
}
|
|
|
|
// OPTION option请求
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2022/05/01 21:32:18
|
|
func OPTION(apiConfig *ApiRequestConfig, param map[string]interface{}) *ApiResponse {
|
|
return nil
|
|
}
|
|
|
|
// Patch patch请求
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2022/05/01 21:36:12
|
|
func Patch(apiConfig *ApiRequestConfig, param map[string]interface{}) *ApiResponse {
|
|
return nil
|
|
}
|
|
|
|
// Trace trace请求
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2022/05/01 21:36:24
|
|
func Trace(apiConfig *ApiRequestConfig, param map[string]interface{}) *ApiResponse {
|
|
return nil
|
|
}
|
|
|
|
// Connect connect请求
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2022/05/01 21:36:39
|
|
func Connect(apiConfig *ApiRequestConfig, param map[string]interface{}) *ApiResponse {
|
|
return nil
|
|
}
|