Documentation
¶
Index ¶
- Constants
- Variables
- func CopyHeader[R RequestResponse](r R) http.Header
- func DeepCopyRequest(r *http.Request) (*http.Request, error)
- func DeepCopyRequestResponse[R RequestResponse](r R) (R, error)
- func DeepCopyResponse(response *http.Response) (*http.Response, error)
- func GetUserAgent(header http.Header) string
- func HeaderContains[Header http.Header | []String | []string | ~string, String ~string](header Header, s String) bool
- func JoinPath(appendRoot bool, segments ...string) string
- func JoinPathR(segments ...string) string
- func NopCloseReadBody[R RequestResponse](r R) (*bytes.Buffer, error)
- func NopCloseReadBodyBuf[R RequestResponse](buf *bytes.Buffer, r R) (int64, error)
- type ContentType
- type RequestResponse
Constants ¶
View Source
const ( UserHeader = "User-ID" OrgHeader = "Org-ID" InternalHeader = "Internal-Client" // 内部服务间调用时使用 InternalActionHeader = "Internal-Action-Client" // action calls the api header RequestIDHeader = "RequestID" UserInfoDesensitizedHeader = "Openapi-Userinfo-Desensitized" LangHeader = "lang" UseTokenHeader = "Use-Token" ContentTypeHeader = "Content-Type" AuthorizationHeader = "Authorization" ClientIDHeader = "Client-ID" ClientNameHeader = "Client-Name" CookieNameOpenapiSession = "OPENAPISESSION" )
dice 公共 Header
Variables ¶
View Source
var ( HeaderKeyContentType = textproto.CanonicalMIMEHeaderKey("content-type") HeaderKeyContentLength = textproto.CanonicalMIMEHeaderKey("content-length") HeaderKeyAccessControlAllowOrigin = textproto.CanonicalMIMEHeaderKey("Access-Control-Allow-Origin") HeaderKeyAuthorization = textproto.CanonicalMIMEHeaderKey("Authorization") HeaderKeyAccept = textproto.CanonicalMIMEHeaderKey("Accept") HeaderKeyAcceptEncoding = textproto.CanonicalMIMEHeaderKey("Accept-Encoding") HeaderKeyUserAgent = textproto.CanonicalMIMEHeaderKey("User-Agent") HeaderKeyContentDisposition = textproto.CanonicalMIMEHeaderKey("Content-Disposition") HeaderKeyContentEncoding = textproto.CanonicalMIMEHeaderKey("Content-Encoding") )
View Source
var (
ContentTypeMultiPartFormData = "multipart/form-data"
)
Functions ¶
func CopyHeader ¶
func CopyHeader[R RequestResponse](r R) http.Header
func DeepCopyRequestResponse ¶
func DeepCopyRequestResponse[R RequestResponse](r R) (R, error)
func GetUserAgent ¶
func HeaderContains ¶
func NopCloseReadBody ¶
func NopCloseReadBody[R RequestResponse](r R) (*bytes.Buffer, error)
NopCloseReadBody is equivalent to the following two functions
func NopCloseReadRequestBody(r *http.Request) ([]byte, error) { if r == nil || r.Body == nil { return nil, nil } var buf bytes.Buffer if _, err := buf.ReadFrom(r.Body); err != nil { return nil, err } if err := r.Body.Close(); err != nil { return nil, err } r.Body = io.NopCloser(&buf) return buf.Bytes(), nil } func NopCloseReadResponseBody(r *http.Response) ([]byte, error) { if r == nil || r.Body == nil { return nil, nil } var buf bytes.Buffer if _, err := buf.ReadFrom(r.Body); err != nil { return nil, err } if err := r.Body.Close(); err != nil { return nil, err } r.Body = io.NopCloser(&buf) return buf.Bytes(), nil }
func NopCloseReadBodyBuf ¶
func NopCloseReadBodyBuf[R RequestResponse](buf *bytes.Buffer, r R) (int64, error)
Types ¶
type ContentType ¶
type ContentType string
const ( ApplicationJson ContentType = "application/json" ApplicationJsonUTF8 ContentType = "application/json; charset=utf-8" TextEventStream ContentType = "text/event-stream" URLEncodedFormMime ContentType = "application/x-www-form-urlencoded" )
Click to show internal directories.
Click to hide internal directories.