Skip to content

Commit

Permalink
style: adjust config
Browse files Browse the repository at this point in the history
  • Loading branch information
ViolaPioggia committed May 26, 2024
1 parent ac162ef commit 52406c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
15 changes: 2 additions & 13 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/cloudwego/hertz/pkg/protocol"
"net/http"
"net/url"
"regexp"
"strings"
"sync"
)
Expand All @@ -49,22 +48,12 @@ type (
)

var (
hdrUserAgentKey = http.CanonicalHeaderKey("User-Agent")
hdrAcceptKey = http.CanonicalHeaderKey("Accept")
hdrContentTypeKey = http.CanonicalHeaderKey("Content-Type")
hdrContentLengthKey = http.CanonicalHeaderKey("Content-Length")
hdrContentEncodingKey = http.CanonicalHeaderKey("Content-Encoding")
hdrLocationKey = http.CanonicalHeaderKey("Location")
hdrAuthorizationKey = http.CanonicalHeaderKey("Authorization")
hdrWwwAuthenticateKey = http.CanonicalHeaderKey("WWW-Authenticate")
hdrContentTypeKey = http.CanonicalHeaderKey("Content-Type")

plainTextType = "text/plain; charset=utf-8"
jsonContentType = "application/json"
formContentType = "application/x-www-form-urlencoded"
formDataContentType = "multipart/form-data"

jsonCheck = regexp.MustCompile(`(?i:(application|text)/(.*json.*)(;|$))`)
xmlCheck = regexp.MustCompile(`(?i:(application|text)/(.*xml.*)(;|$))`)
)

func createClient(cc *client.Client) *Client {
Expand Down Expand Up @@ -218,7 +207,7 @@ func (c *Client) SetFormContentType() *Client {

}

func (c *Client) SetXFormData() *Client {
func (c *Client) SetFormData() *Client {
c.Header.Set("Content-Type", "multipart/form-data")
return c
}
Expand Down
12 changes: 2 additions & 10 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ func (r *Request) AddHeaderMultiValues(headers map[string][]string) *Request {
return r
}

// [] SetContentType(contentType string)
// [] SetJSONContentType() (可添加一些常用的 content-type)
func (r *Request) SetCookie(hc *http.Cookie) *Request {
r.RawRequest.SetCookie(hc.Name, hc.Value)
return r
Expand All @@ -177,8 +175,6 @@ func (r *Request) SetCookies(rs []*http.Cookie) *Request {
return r
}

// [] SetJSONBody(body interface{}) (自动注入 json content-type,参数可以是 strcut、map、[]byte、string 等)
// [] SetUrlEncodeBody(body url.Value) (自动注入 urlencode content-type)
func (r *Request) SetBody(body interface{}) *Request {
r.BodyParams = body
return r
Expand Down Expand Up @@ -226,16 +222,12 @@ func (r *Request) SetResult(res interface{}) *Request {
return r
}

// [] WithContext(ctx)
// [] WithDC(dc)
// [] WithCluster(cluster)
// [] WithEnv(env)
// [] WIthCallTimeout(t)
func (r *Request) WithContext(ctx context.Context) *Request {
r.Ctx = ctx
return r
}
func (r *Request) WithDC() *Request {
func (r *Request) WithDC(ctx context.Context) *Request {

return r
}
func (r *Request) WithCluster() *Request {
Expand Down

0 comments on commit 52406c3

Please sign in to comment.