Documentation ¶
Index ¶
- Constants
- func AccessMapValue(val interface{}, path string) interface{}
- func Ajax(method, url string, jsonStr []byte, headers StrMap) ([]byte, error)
- func AjaxGet(url string, headers StrMap) ([]byte, error)
- func AjaxGetRequest(url string, headers StrMap) (*http.Request, error)
- func AjaxGetUnmarshal(url string, headers StrMap, v interface{}) error
- func AjaxPost(url string, jsonStr []byte, headers StrMap) ([]byte, error)
- func AjaxPostRequest(url string, jsonStr []byte, headers StrMap) (*http.Request, error)
- func AjaxPostUnmarshal(url string, jsonStr []byte, headers StrMap, v interface{}) error
- func AjaxPut(url string, jsonStr []byte, headers StrMap) ([]byte, error)
- func AjaxPutRequest(url string, jsonStr []byte, headers StrMap) (*http.Request, error)
- func AjaxPutUnmarshal(url string, jsonStr []byte, headers StrMap, v interface{}) error
- func AjaxRequest(method, url string, data []byte, headers StrMap) (*http.Request, error)
- func AjaxUnmarshal(method, url string, jsonStr []byte, headers StrMap, ret interface{}) error
- func CamelToSlug(str string) string
- func CamelToSnake(str string) string
- func CharIn(ch rune, chs ...rune) bool
- func ContainsRecursive(v1, v2 interface{}) bool
- func ContainsString(arr []string, str string) bool
- func ContextWithMap(ctx context.Context, maps ...map[string]interface{}) context.Context
- func Crand31() int32
- func Crand63() int64
- func CrandBytes(sz int) ([]byte, error)
- func CrandInt() int
- func CrandSouce() rand.Source
- func CutHalf(s string, chs ...rune) (string, string)
- func CutLeft(s string, chs ...rune) string
- func CutRight(s string, chs ...rune) string
- func DecodeRequestBody(req *http.Request, strict bool, ret interface{}) error
- func DefaultParamListString(args ...string) string
- func DirExists(basePath, relPath string) bool
- func ErrorCode(err error, otherwise int) int
- func Exec(wd, stdoutPath, binPath string, args ...string) error
- func FileExists(basePath string, relPaths ...string) bool
- func FormDo(method, url string, data, headers StrMap) (*http.Response, error)
- func FormRequest(method, url string, data, headers StrMap) (*http.Request, error)
- func GetExistingFileInfo(basePath string, relPaths ...string) (os.FileInfo, string, error)
- func GetField(val interface{}, name string) (interface{}, error)
- func GetMapKeys(val interface{}) ([]string, error)
- func GetMapValue(val interface{}, path []string) interface{}
- func GetRequest(url, contentType string, headers StrMap) (*http.Request, error)
- func HandleError(w http.ResponseWriter, err error, statusCode int) bool
- func HasContentType(r *http.Request, mimetype string) bool
- func HasField(val interface{}, name string, expected interface{}) bool
- func HasNil(vs ...interface{}) bool
- func Http(method, url, contentType string, data []byte, headers StrMap) ([]byte, error)
- func HttpCall(method, url, contentType string, data []byte, headers StrMap) ([]byte, *http.Response, error)
- func HttpDo(method, url, contentType string, data []byte, headers StrMap) (*http.Response, error)
- func HttpGet(url string) ([]byte, error)
- func HttpRequest(method, url, contentType string, data []byte, headers StrMap) (*http.Request, error)
- func HttpSend(method, url string, data []byte, headers StrMap) ([]byte, error)
- func IndexOfChar(s string, chs ...rune) int
- func IndexOfString(arr []string, str string) int
- func IsBasic(val interface{}) bool
- func IsError(err error, code int) bool
- func IsNil(v interface{}) bool
- func IsNilPtr(v interface{}) bool
- func IsNotFound(err error) bool
- func IsNull(v Nilable) bool
- func IsStringKeyMap(v interface{}) bool
- func IsType(v interface{}, t reflect.Type) bool
- func IsUnauthorized(err error) bool
- func JsonContains(s1, s2 []byte) bool
- func JsonEqual(s1, s2 []byte) bool
- func JsonMarshalContains(i1, i2 interface{}) bool
- func JsonStrContains(s1, s2 string) bool
- func JsonStrEqual(s1, s2 string) bool
- func MapAllKeysExist(m Map, keys ...string) bool
- func MapContainsBasic(m, n Map) bool
- func MapKeys(m Map) []string
- func MaxFloat64(arr []float64) float64
- func MergeStrMap(dest, src map[string]string, srcs ...map[string]string) map[string]string
- func MinFloat64(arr []float64) float64
- func NewCryptoSeededSource() rand.Source
- func NewCryptoSource() cryptoSrc
- func NewResponseWriter() *responseWriter
- func ParamListString(sep, keySep rune, args ...string) string
- func Params(args ...string) map[string]string
- func ParamsString(params map[string]string, args ...string) string
- func ParseParams(params string, sep string, keySeps ...string) map[string]string
- func Rand31() int32
- func Rand63() int64
- func RandInt() int
- func RandSouce() rand.Source
- func RandString(n int) string
- func ReadRequestBody(req *http.Request) ([]byte, error)
- func ReadResponseBody(res *http.Response) ([]byte, error)
- func RelayResponse(w http.ResponseWriter, res *http.Response)
- func ResolveExistingDir(basePath, relPath string) (string, error)
- func ResolveExistingFile(basePath, relPath string) (string, error)
- func ResolvePath(basePath string, relPaths ...string) (string, error)
- func SimpleAjaxDo(method, url string, data Map, headers StrMap) (*http.Request, error)
- func SimpleAjaxRequest(method, url string, data Map, headers StrMap) (*http.Request, error)
- func SimpleAjaxUnmarshal(method, url string, data Map, headers StrMap, ret interface{}) error
- func SimpleErrHandler(err error, res *http.Response, w http.ResponseWriter, req *http.Request)
- func SimpleJsonData(values map[string]string, kinds ...string) []byte
- func SimpleJsonErrHandler(err error, res *http.Response, w http.ResponseWriter, req *http.Request)
- func SimpleJsonError(msg string, codes ...int) []byte
- func SlugToCamel(str string, capital bool) string
- func Slugify(str, sep string) string
- func SnakeToCamel(str string, capital bool) string
- func StrMapAllKeysExist(m StrMap, keys ...string) bool
- func StrMapAllNonEmpty(m StrMap, keys ...string) bool
- func StrMapContains(m, n StrMap) bool
- func StrMapKeys(m StrMap) []string
- func StructFieldNames(val interface{}) []string
- func StructToBasicMap(val interface{}) map[string]interface{}
- func StructToMap(val interface{}, keys ...string) (map[string]interface{}, error)
- func UnmarshalRequest(req *http.Request, ret interface{}) error
- func UnmarshalResponse(res *http.Response, ret interface{}) error
- func UriHandler(hostPort string, errHandler ErrHandler) (*urlHandler, error)
- type BufferError
- type BytesBufferError
- type CircularQueue
- type Data
- type ErrHandler
- type Error
- type ErrorItem
- type FloatQueue
- type JsonMsg
- type Map
- func OmitMap(m Map, skips ...string) Map
- func PickMap(m Map, keys ...string) Map
- func SimpleAjax(method, url string, data Map, headers StrMap) (Map, error)
- func SimpleAjaxGet(url string, headers StrMap) (Map, error)
- func SimpleAjaxPost(url string, data Map, headers StrMap) (Map, error)
- func SimpleAjaxPut(url string, data Map, headers StrMap) (Map, error)
- func StrMapToMap(m StrMap) Map
- type Nilable
- type QueueReducer
- type StrMap
Constants ¶
const ( BadRequest = 400 Forbidden = 403 NotFound = 404 InternalServerError = 500 )
Variables ¶
This section is empty.
Functions ¶
func AccessMapValue ¶
func AccessMapValue(val interface{}, path string) interface{}
func AjaxGetUnmarshal ¶
func AjaxPostRequest ¶
func AjaxPostUnmarshal ¶
func AjaxPutRequest ¶
func AjaxPutUnmarshal ¶
func AjaxRequest ¶
func AjaxUnmarshal ¶
func CamelToSlug ¶
func CamelToSnake ¶
func ContainsRecursive ¶
func ContainsRecursive(v1, v2 interface{}) bool
only concerns string keyed map sub-structure - slices, pointers, structs, etc are compared via deepEqual
func ContainsString ¶
func ContextWithMap ¶
func CrandBytes ¶
func CrandSouce ¶
func DecodeRequestBody ¶
func DefaultParamListString ¶
func FileExists ¶
func FormRequest ¶
func GetExistingFileInfo ¶
return fpath even not exists
func GetMapKeys ¶
GetMapKeys return keys only for string-keyed map
func GetMapValue ¶
func GetMapValue(val interface{}, path []string) interface{}
func HandleError ¶
func HandleError(w http.ResponseWriter, err error, statusCode int) bool
func HasContentType ¶
Failure should yield an HTTP 415 (`http.StatusUnsupportedMediaType`)
func HttpRequest ¶
func IndexOfChar ¶
func IndexOfString ¶
func IsNilPtr ¶
func IsNilPtr(v interface{}) bool
panic on purpose (for interface param known to be struct pointer)
func IsNotFound ¶
func IsStringKeyMap ¶
func IsStringKeyMap(v interface{}) bool
func IsUnauthorized ¶
func JsonContains ¶
func JsonMarshalContains ¶
func JsonMarshalContains(i1, i2 interface{}) bool
func JsonStrContains ¶
func JsonStrEqual ¶
func MapAllKeysExist ¶
func MapContainsBasic ¶
func MaxFloat64 ¶
func MergeStrMap ¶
func MinFloat64 ¶
func NewCryptoSeededSource ¶
func NewCryptoSource ¶
func NewCryptoSource() cryptoSrc
func NewResponseWriter ¶
func NewResponseWriter() *responseWriter
func ParamListString ¶
no checking, use with care
func ParamsString ¶
args[0] the separator, args[1] the key-value separator
func RandString ¶
func RelayResponse ¶
func RelayResponse(w http.ResponseWriter, res *http.Response)
func ResolveExistingDir ¶
func ResolveExistingFile ¶
func ResolvePath ¶
return fpath even if bad basePath
func SimpleAjaxDo ¶
func SimpleAjaxRequest ¶
func SimpleAjaxUnmarshal ¶
func SimpleErrHandler ¶
func SimpleJsonErrHandler ¶
func SimpleJsonError ¶
func SlugToCamel ¶
func SnakeToCamel ¶
func StrMapAllKeysExist ¶
func StrMapAllNonEmpty ¶
func StrMapContains ¶
func StrMapKeys ¶
func StructFieldNames ¶
func StructFieldNames(val interface{}) []string
func StructToBasicMap ¶
func StructToBasicMap(val interface{}) map[string]interface{}
func StructToMap ¶
func UnmarshalRequest ¶
func UnmarshalResponse ¶
Marshal/unmarshal all mean json, all ignore whether Content-Type is applicattion/json - maybe check if content-type is application/json later
func UriHandler ¶
func UriHandler(hostPort string, errHandler ErrHandler) (*urlHandler, error)
Types ¶
type BufferError ¶
BufferError is not really of an error type but to "tunnel" return data from functions that only return errors
type BytesBufferError ¶
func NewBufferError ¶
func NewBufferError(msg string, data []byte) *BytesBufferError
func NewJsonError ¶
func NewJsonError(msg string, data interface{}) *BytesBufferError
func NewStringError ¶
func NewStringError(msg, data string) *BytesBufferError
func (BytesBufferError) Error ¶
func (e BytesBufferError) Error() string
type CircularQueue ¶
type CircularQueue struct {
// contains filtered or unexported fields
}
func NewCircularQueue ¶
func NewCircularQueue(size int, baseValue interface{}, initItems []interface{}, reducer QueueReducer) *CircularQueue
func (*CircularQueue) Clear ¶
func (k *CircularQueue) Clear()
func (*CircularQueue) Enqueue ¶
func (k *CircularQueue) Enqueue(val interface{})
func (*CircularQueue) Item ¶
func (k *CircularQueue) Item(idx int) interface{}
func (*CircularQueue) Length ¶
func (k *CircularQueue) Length() int
func (*CircularQueue) Size ¶
func (k *CircularQueue) Size() int
func (*CircularQueue) Sum ¶
func (k *CircularQueue) Sum() interface{}
type Data ¶
type ErrHandler ¶
type Error ¶
type Error struct { Code int `json:"code,omitempty"` Message string `json:"message,omitempty"` Errors []ErrorItem `json:"errors,omitempty"` }
func NotFoundError ¶
type FloatQueue ¶
type FloatQueue struct {
// contains filtered or unexported fields
}
func NewFloatQueue ¶
func (*FloatQueue) Clear ¶
func (k *FloatQueue) Clear()
func (*FloatQueue) Enqueue ¶
func (k *FloatQueue) Enqueue(val float64)
func (*FloatQueue) Item ¶
func (k *FloatQueue) Item(idx int) float64
func (*FloatQueue) Items ¶
func (k *FloatQueue) Items() []float64
func (*FloatQueue) Length ¶
func (k *FloatQueue) Length() int
func (*FloatQueue) Size ¶
func (k *FloatQueue) Size() int
func (*FloatQueue) Sum ¶
func (k *FloatQueue) Sum() float64
type QueueReducer ¶
type QueueReducer interface { Add(base, val interface{}) interface{} Sub(base, val interface{}) interface{} }