Documentation
¶
Index ¶
- Constants
- Variables
- func AnyOf(s string, p ...string) bool
- func CORSMiddleware(c *gin.Context)
- func CompactJSON(b []byte) []byte
- func ConvertHeader(query map[string][]string) map[string]string
- func DetectContentType(b []byte) string
- func GetFormBody(c *gin.Context) map[string]string
- func GetHeaders(c *gin.Context) map[string]string
- func GetMultiPartFormValue(c *gin.Context) interface{}
- func GetRequestBody(c *gin.Context) interface{}
- func GinData(c *gin.Context, b []byte)
- func HasContentType(r *http.Request, mimetype string) bool
- func HasPrefix(s string, p ...string) bool
- func IsJSONBytes(b []byte) bool
- func IsRelativeForward(statusCode int, locationHeader string) bool
- func JSON(v interface{}) []byte
- func JoinLowerKeys(s ...string) string
- func OpenExplorerWithContext(contextPath, port string)
- func Or(s, or string) string
- func ReverseProxy(originalPath, targetHost, targetPath string) *httputil.ReverseProxy
- func TimeFmt(t time.Time) string
- func TryBind(c *gin.Context) interface{}
- func UnquoteCover(s, start, end string) string
- type Dialer
- type GinCopyWriter
- type ReplaceItem
- type Replacer
- type Throttle
Constants ¶
const ( ContentTypeText = "text/plain; charset=utf-8" ContentTypeJSON = "application/json; charset=utf-8" )
Variables ¶
var Transport = &http.Transport{DialContext: TimeoutDialer(30*time.Second, 30*time.Second)}
Functions ¶
func CompactJSON ¶
CompactJSON compact a json byte slice or wrap it to raw value.
func ConvertHeader ¶
ConvertHeader convert s head map[string][]string to map[string]string.
func DetectContentType ¶
DetectContentType detects the contentType of b.
func GetMultiPartFormValue ¶
GetMultiPartFormValue ...
func HasContentType ¶
HasContentType determine whether the request `content-type` includes a server-acceptable mime-type Failure should yield an HTTP 415 (`http.StatusUnsupportedMediaType`)
func IsRelativeForward ¶
IsRelativeForward tells the statusCode is 301/302 and locationHeader is relative
func OpenExplorerWithContext ¶
func OpenExplorerWithContext(contextPath, port string)
OpenExplorerWithContext ...
func ReverseProxy ¶
func ReverseProxy(originalPath, targetHost, targetPath string) *httputil.ReverseProxy
ReverseProxy reverse proxy originalPath to targetHost with targetPath. And the relative forwarding is rewritten.
func UnquoteCover ¶
UnquoteCover unquotes string from s.
Types ¶
type Dialer ¶
Dialer defines dialer function alias
func TimeoutDialer ¶
TimeoutDialer returns functions of connection dialer with timeout settings for http.Transport Dial field. https://gist.github.com/c4milo/275abc6eccbfd88ad56ca7c77947883a HTTP client with support for read and write timeouts which are missing in Go's standard library.
type GinCopyWriter ¶
type GinCopyWriter struct {
gin.ResponseWriter
Buf bytes.Buffer
}
func NewGinCopyWriter ¶
func NewGinCopyWriter(w gin.ResponseWriter) *GinCopyWriter
NewGinCopyWriter creates a new GinCopyWriter.
func (*GinCopyWriter) Body ¶
func (w *GinCopyWriter) Body(maxSize int) string
func (*GinCopyWriter) Bytes ¶
func (w *GinCopyWriter) Bytes() []byte
func (*GinCopyWriter) WriteString ¶
func (w *GinCopyWriter) WriteString(s string) (n int, err error)
type ReplaceItem ¶
type Throttle ¶
type Throttle struct {
// contains filtered or unexported fields
}
Throttle ...
func MakeThrottle ¶
MakeThrottle ...