util

package
v0.0.0-...-d38aeb8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParamNotFound = errors.New("param not found")
)

Functions

func DumpConfig

func DumpConfig(c interface{}) string

func FileExists

func FileExists(path string) bool

func FormRedirectUrl

func FormRedirectUrl(old string, redirect string) (string, error)

func FormURL

func FormURL(server, path string) string

func GetHttpClientDebugMode

func GetHttpClientDebugMode() bool

func GetIPList

func GetIPList() []string

func HasFlag

func HasFlag(name string) bool

func HasQueryParam

func HasQueryParam(req *http.Request, param string) (bool, error)

func JoinURL

func JoinURL(p1, p2 string) string

func LoadJsonConfig

func LoadJsonConfig(path string, c interface{}) error

func MaxInt

func MaxInt(a, b int) int

func MinInt

func MinInt(a, b int) int

func ParseJsonRequest

func ParseJsonRequest(r *http.Request, out interface{}) error

func QueryParam

func QueryParam(req *http.Request, param string) (string, error)

func SetHttpClientDebugMode

func SetHttpClientDebugMode(flag bool)

func SplitListArg

func SplitListArg(arg string, seperator string) []string

func WriteErrorResponse

func WriteErrorResponse(w http.ResponseWriter, statusCode int, err error)

func WriteSuccessResponse

func WriteSuccessResponse(w http.ResponseWriter)

func WriteSuccessResponseWithData

func WriteSuccessResponseWithData(w http.ResponseWriter, data interface{})

Types

type GenericJsonResp

type GenericJsonResp struct {
	Success bool        `json:"success"`
	Error   string      `json:"error,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

type HttpClient

type HttpClient struct {
	// contains filtered or unexported fields
}
var DefaultHttpClient *HttpClient

func NewHttpClient

func NewHttpClient(cfg *HttpClientConfig) (*HttpClient, error)

func (*HttpClient) Do

func (c *HttpClient) Do(req *http.Request) (*http.Response, error)

func (*HttpClient) DoGetAndParseResult

func (c *HttpClient) DoGetAndParseResult(url string, result interface{}) error

func (*HttpClient) DoJsonPost

func (c *HttpClient) DoJsonPost(url string, data interface{}) (*http.Response, error)

func (*HttpClient) DoJsonPostAndParseResult

func (c *HttpClient) DoJsonPostAndParseResult(url string,
	data interface{}, result interface{}) error

func (*HttpClient) DoRequestParseResult

func (c *HttpClient) DoRequestParseResult(method, url string, result interface{}) error

func (*HttpClient) DumpRequest

func (c *HttpClient) DumpRequest(req *http.Request, w io.Writer)

func (*HttpClient) DumpResponse

func (c *HttpClient) DumpResponse(resp *http.Response, w io.Writer)

func (*HttpClient) ParseJsonResp

func (c *HttpClient) ParseJsonResp(resp *http.Response, result interface{}) error

type HttpClientConfig

type HttpClientConfig struct {
	Proxy            string
	NoFollowRedirect bool
	NoTLSVerify      bool
	DialTimeout      time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL