Documentation ¶
Overview ¶
Gypsy is a simplified YAML parser written in Go. It is intended to be used as a simple configuration file, and as such does not support a lot of the more nuanced syntaxes allowed in full-fledged YAML. YAML does not allow indent with tabs, and GYPSY does not ever consider a tab to be a space character. It is recommended that your editor be configured to convert tabs to spaces when editing Gypsy config files.
Gypsy understands the following to be a list:
- one
- two
- three
This is parsed as a `yaml.YamlList`, and can be retrieved from the `yaml.YamlNode.YamlList()` method. In this case, each element of the `yaml.YamlList` would be a `yaml.YamlScalar` whose value can be retrieved with the `yaml.YamlScalar.String()` method.
Gypsy understands the following to be a mapping:
key: value foo: bar running: away
A mapping is an unordered list of `key:value` pairs. All whitespace after the colon is stripped from the value and is used for alignment purposes during export. If the value is not a list or a map, everything after the first non-space character until the end of the line is used as the `yaml.YamlScalar` value.
Gypsy allows arbitrary nesting of maps inside lists, lists inside of maps, and maps and/or lists nested inside of themselves.
A map inside of a list:
- name: John Smith age: 42
- name: Jane Smith age: 45
A list inside of a map:
schools: - Meadow Glen - Forest Creek - Shady Grove libraries: - Joseph Hollingsworth Memorial - Andrew Keriman Memorial
A list of lists:
- - one
- two
- three
- - un
- deux
- trois
- - ichi
- ni
- san
A map of maps:
google: company: Google, Inc. ticker: GOOG url: http://google.com/ yahoo: company: Yahoo, Inc. ticker: YHOO url: http://yahoo.com/
In the case of a map of maps, all sub-keys must be on subsequent lines and indented equally. It is allowable for the first key/value to be on the same line if there is more than one key/value pair, but this is not recommended.
Values can also be expressed in long form (leading whitespace of the first line is removed from it and all subsequent lines). In the normal (baz) case, newlines are treated as spaces, all indentation is removed. In the folded case (bar), newlines are treated as spaces, except pairs of newlines (e.g. a blank line) are treated as a single newline, only the indentation level of the first line is removed, and newlines at the end of indented lines are preserved. In the verbatim (foo) case, only the indent at the level of the first line is stripped. The example:
foo: | lorem ipsum dolor sit amet bar: > lorem ipsum dolor sit amet baz: lorem ipsum dolor sit amet
The YAML subset understood by Gypsy can be expressed (loosely) in the following grammar (not including comments):
OBJECT = MAPPING | SEQUENCE | SCALAR . SHORT-OBJECT = SHORT-MAPPING | SHORT-SEQUENCE | SHORT-SCALAR . EOL = '\n' MAPPING = { LONG-MAPPING | SHORT-MAPPING } . SEQUENCE = { LONG-SEQUENCE | SHORT-SEQUENCE } . SCALAR = { LONG-SCALAR | SHORT-SCALAR } . LONG-MAPPING = { INDENT KEY ':' OBJECT EOL } . SHORT-MAPPING = '{' KEY ':' SHORT-OBJECT { ',' KEY ':' SHORT-OBJECT } '}' EOL . LONG-SEQUENCE = { INDENT '-' OBJECT EOL } EOL . SHORT-SEQUENCE = '[' SHORT-OBJECT { ',' SHORT-OBJECT } ']' EOL . LONG-SCALAR = ( '|' | '>' | ) EOL { INDENT SHORT-SCALAR EOL } SHORT-SCALAR = { alpha | digit | punct | ' ' | '\t' } . KEY = { alpha | digit } INDENT = { ' ' }
Any line where the first non-space character is a sharp sign (#) is a comment. It will be ignored. Only full-line comments are allowed.
Index ¶
- Constants
- Variables
- func AESDecrypt(value, key string) string
- func AESEncrypt(value, key string) string
- func ArrayContains(aStr string, arr []string) bool
- func ArrayContainsIgnoreCase(aStr string, arr []string) bool
- func ArrayIndexOf(aStr string, arr []string) int
- func ArrayIndexOfIgnoreCase(aStr string, arr []string) int
- func Bool(node YamlNode, spec string) (bool, error)
- func BoolChild(root YamlNode, spec string) (bool, error)
- func Condition(cond bool, trueVal, falseVal interface{}) interface{}
- func DecryptByRSAKey(cipherBytes []byte, privateKey *rsa.PrivateKey) ([]byte, error)
- func DecryptByRSAKeyString(cipherBytes []byte, privateKeyString string) ([]byte, error)
- func DefaultIfNil(val, def interface{}) interface{}
- func DumpRequest(handlerFunc http.HandlerFunc) http.HandlerFunc
- func EncryptByRSAKey(plainBytes []byte, publicKey *rsa.PublicKey) ([]byte, error)
- func EncryptByRSAKeyString(plainBytes []byte, publicKeyString string) ([]byte, error)
- func FirstNonLoopbackAddress() (net.IP, error)
- func FormIntValue(request *http.Request, key string) int
- func FormIntValueDefault(request *http.Request, key string, defaultValue int) int
- func GetIpInt64() (int64, error)
- func GzipResponse(handlerFunc http.HandlerFunc) http.HandlerFunc
- func HandleFunc(mux *http.ServeMux, path string, handler http.HandlerFunc, ...)
- func HmacSha256Base64(plainText string, key string) string
- func If(cond bool, trueFunc func())
- func Int(node YamlNode, spec string) (int64, error)
- func Int64FromStr(str string) (int64, error)
- func IntChild(root YamlNode, spec string) (int64, error)
- func IntFromStr(str string) (int, error)
- func IsAjaxRequest(request *http.Request) bool
- func Json(v interface{}) string
- func ListChildCount(root YamlNode, spec string) (int, error)
- func ListCount(node YamlNode, spec string) (int, error)
- func MinifyCSS(cssString string, devMode bool) string
- func MinifyHTML(htmlString string, devMode bool) string
- func MinifyJs(jsString string, devMode bool) string
- func NextId() string
- func PathJoin(elem ...string) string
- func RSAPrivateKeyDecoded(privateKeyString string) (*rsa.PrivateKey, error)
- func RSAPublicKeyDecoded(publicKeyString string) (*rsa.PublicKey, error)
- func RandomString(length int) string
- func RequestBody(request *http.Request) (string, error)
- func ResponseContent(writer http.ResponseWriter, content, contentType, characterEncoding string)
- func ResponseErrorContent(writer http.ResponseWriter, statusCode int, ...)
- func ResponseErrorHtml(writer http.ResponseWriter, statusCode int, html string)
- func ResponseErrorJson(writer http.ResponseWriter, statusCode int, json string)
- func ResponseErrorText(writer http.ResponseWriter, statusCode int, text string)
- func ResponseHtml(writer http.ResponseWriter, html string)
- func ResponseJson(writer http.ResponseWriter, json string)
- func ResponseText(writer http.ResponseWriter, text string)
- func ReverseProxy(target *url.URL) *httputil.ReverseProxy
- func ServeAjax(handlerFunc http.HandlerFunc) http.HandlerFunc
- func ServeGet(handlerFunc http.HandlerFunc) http.HandlerFunc
- func ServeMethod(handlerFunc http.HandlerFunc, httpMethods ...string) http.HandlerFunc
- func ServeModelContext(handlerFunc http.HandlerFunc) http.HandlerFunc
- func ServeModelContextWithValueFunc(handlerFunc http.HandlerFunc, valueFunc ModelCtxValueFunc) http.HandlerFunc
- func ServePost(handlerFunc http.HandlerFunc) http.HandlerFunc
- func ServeRedirect(redirect string) http.HandlerFunc
- func StrFromInt(i int) string
- func StrFromInt64(i int64) string
- func String(node YamlNode, spec string) (string, error)
- func StringChild(root YamlNode, spec string) (string, error)
- func ToBool(str string) bool
- func UnJson(str string, v interface{}) interface{}
- func Unless(cond bool, falseFunc func())
- func ValOrFunc(val interface{}) interface{}
- func YamlRender(node YamlNode) string
- type CacheItem
- func (item *CacheItem) AccessCount() int64
- func (item *CacheItem) AccessedOn() time.Time
- func (item *CacheItem) CreatedOn() time.Time
- func (item *CacheItem) Data() interface{}
- func (item *CacheItem) KeepAlive()
- func (item *CacheItem) Key() interface{}
- func (item *CacheItem) LifeSpan() time.Duration
- func (item *CacheItem) SetAboutToExpireCallback(f func(interface{}))
- type CacheItemPair
- type CacheItemPairList
- type CacheTable
- func (table *CacheTable) Add(key interface{}, lifeSpan time.Duration, data interface{}) *CacheItem
- func (table *CacheTable) Count() int
- func (table *CacheTable) Delete(key interface{}) (*CacheItem, error)
- func (table *CacheTable) Exists(key interface{}) bool
- func (table *CacheTable) Flush()
- func (table *CacheTable) Foreach(trans func(key interface{}, item *CacheItem))
- func (table *CacheTable) LoadingAdd(key interface{}, args ...interface{}) (*CacheItem, error)
- func (table *CacheTable) MostAccessed(count int64) []*CacheItem
- func (table *CacheTable) NotFoundAdd(key interface{}, lifeSpan time.Duration, data interface{}) bool
- func (table *CacheTable) SetAboutToDeleteItemCallback(f func(*CacheItem))
- func (table *CacheTable) SetAddedItemCallback(f func(*CacheItem))
- func (table *CacheTable) SetDataLoader(f func(interface{}, ...interface{}) (*CacheItem, error))
- func (table *CacheTable) SetLogger(logger *log.Logger)
- func (table *CacheTable) Value(key interface{}, args ...interface{}) (*CacheItem, error)
- type Duration
- type ExpireStrategy
- type GzipResponseWriter
- type HandleFuncOption
- type HandleFuncOptions
- type Hashset
- type Hashtable
- type HttpDownload
- type HttpDownloadDelegate
- type HttpDownloadDelegateOption
- func WithDownloadDidFailWithError(f func(*HttpDownload, error)) HttpDownloadDelegateOption
- func WithDownloadDidFinish(f func(*HttpDownload)) HttpDownloadDelegateOption
- func WithDownloadDidStarted(f func(*HttpDownload)) HttpDownloadDelegateOption
- func WithDownloadingProgressInterval(interval time.Duration) HttpDownloadDelegateOption
- func WithDownloadingWithProgress(f func(*HttpDownload, float64)) HttpDownloadDelegateOption
- type HttpDownloadDelegateOptions
- type HttpDownloadOption
- type HttpDownloadOptions
- type HttpReq
- func (httpReq *HttpReq) Cookie(cookie *http.Cookie) *HttpReq
- func (httpReq *HttpReq) Get() (string, error)
- func (httpReq *HttpReq) Params(name string, value string, more ...string) *HttpReq
- func (httpReq *HttpReq) ParamsMapping(params map[string]string) *HttpReq
- func (httpReq *HttpReq) Post() (string, error)
- func (httpReq *HttpReq) Prop(name string, value string) *HttpReq
- func (httpReq *HttpReq) Req(req string) *HttpReq
- func (httpReq *HttpReq) RequestBody(requestBody string) *HttpReq
- type HttpServerConfig
- type LineReader
- type LineReaderException
- type ModelCtx
- type ModelCtxValueFunc
- type Properties
- func (properties *Properties) GetProperty(key string) string
- func (properties *Properties) GetPropertyDefault(key, defaultValue string) string
- func (properties *Properties) List(out io.Writer)
- func (properties *Properties) Load(reader io.Reader) error
- func (properties *Properties) PropertyNames() []interface{}
- func (properties *Properties) Save(writer io.Writer, comments string)
- func (properties *Properties) SetProperty(key string, value string)
- func (properties *Properties) Store(writer io.Writer, comments string) error
- func (properties *Properties) StringPropertyNames() []string
- func (properties *Properties) ToMap() map[interface{}]interface{}
- type RSAKeyPair
- type RecFunc
- type Signer
- func (s *Signer) SignBase64ByRSAKey(plainText string, privateKey *rsa.PrivateKey) (string, error)
- func (s *Signer) SignBase64ByRSAKeyString(plainText, privateKeyString string) (string, error)
- func (s *Signer) SignByRSAKey(plainText string, privateKey *rsa.PrivateKey) ([]byte, error)
- func (s *Signer) SignByRSAKeyString(plainText, privateKeyString string) ([]byte, error)
- func (s *Signer) VerifyBase64ByRSAKey(plainText, signText string, publicKey *rsa.PublicKey) error
- func (s *Signer) VerifyBase64ByRSAKeyString(plainText, signText, publicKeyString string) error
- func (s *Signer) VerifyByRSAKey(plainText string, sign []byte, publicKey *rsa.PublicKey) error
- func (s *Signer) VerifyByRSAKeyString(plainText string, sign []byte, publicKeyString string) error
- type YamlFile
- func (f *YamlFile) GetBool(spec string) (bool, error)
- func (f *YamlFile) GetInt(spec string) (int64, error)
- func (f *YamlFile) GetList(spec string) (YamlList, error)
- func (f *YamlFile) GetListCount(spec string) (int, error)
- func (f *YamlFile) GetMap(spec string) (YamlMap, error)
- func (f *YamlFile) GetNode(spec string) (YamlNode, error)
- func (f *YamlFile) GetScalar(spec string) (YamlScalar, error)
- func (f *YamlFile) GetString(spec string) (string, error)
- func (f *YamlFile) RooListCount() (int, error)
- func (f *YamlFile) RootBool() (bool, error)
- func (f *YamlFile) RootInt() (int64, error)
- func (f *YamlFile) RootList() (YamlList, error)
- func (f *YamlFile) RootMap() (YamlMap, error)
- func (f *YamlFile) RootScalar() (YamlScalar, error)
- func (f *YamlFile) RootString() (string, error)
- type YamlList
- type YamlMap
- type YamlNode
- type YamlNodeNotFound
- type YamlNodeTypeMismatch
- type YamlScalar
- Bugs
Constants ¶
const ( ExpireAfterWrite = 0 ExpireAfterAccess = 1 )
Variables ¶
var ( // ErrCacheKeyNotFound gets returned when a specific key couldn't be found ErrCacheKeyNotFound = errors.New("key not found in cache") // ErrCacheKeyNotFoundOrLoadable gets returned when a specific key couldn't be // found and loading via the data-loader callback also failed ErrCacheKeyNotFoundOrLoadable = errors.New("key not found and could not be loaded into cache") )
var ( SHA1WithRSA = Signer{/* contains filtered or unexported fields */} SHA256WithRSA = Signer{/* contains filtered or unexported fields */} )
var ContextPathDisabled = func(o *HandleFuncOptions) { o.ContextPathEnabled = false }
var ContextPathEnabled = func(o *HandleFuncOptions) { o.ContextPathEnabled = true }
var DumpRequestDisabled = func(o *HandleFuncOptions) { o.DumpRequestEnabled = false }
var DumpRequestEnabled = func(o *HandleFuncOptions) { o.DumpRequestEnabled = true }
var EmptyHandler http.HandlerFunc = func(_ http.ResponseWriter, _ *http.Request) {}
var GzipResponseDisabled = func(o *HandleFuncOptions) { o.GzipResponseEnabled = false }
var GzipResponseEnabled = func(o *HandleFuncOptions) { o.GzipResponseEnabled = true }
var ModelContextDisabled = func(o *HandleFuncOptions) { o.ModelContextEnabled = false }
var ModelContextEnabled = func(o *HandleFuncOptions) { o.ModelContextEnabled = true }
var ReverseProxyUserAgent = ""
Functions ¶
func AESDecrypt ¶ added in v0.5.0
func AESEncrypt ¶ added in v0.5.0
func ArrayContains ¶ added in v0.3.1
func ArrayContainsIgnoreCase ¶ added in v0.3.1
func ArrayIndexOf ¶ added in v0.3.1
func ArrayIndexOfIgnoreCase ¶ added in v0.3.1
func DecryptByRSAKey ¶ added in v0.6.0
func DecryptByRSAKey(cipherBytes []byte, privateKey *rsa.PrivateKey) ([]byte, error)
func DecryptByRSAKeyString ¶ added in v0.6.0
func DefaultIfNil ¶
func DefaultIfNil(val, def interface{}) interface{}
func DumpRequest ¶ added in v0.5.0
func DumpRequest(handlerFunc http.HandlerFunc) http.HandlerFunc
func EncryptByRSAKey ¶ added in v0.6.0
func EncryptByRSAKeyString ¶ added in v0.6.0
func FirstNonLoopbackAddress ¶ added in v0.6.0
func FormIntValueDefault ¶ added in v0.5.0
func GetIpInt64 ¶ added in v0.6.0
func GzipResponse ¶ added in v0.5.0
func GzipResponse(handlerFunc http.HandlerFunc) http.HandlerFunc
func HandleFunc ¶ added in v0.5.0
func HandleFunc(mux *http.ServeMux, path string, handler http.HandlerFunc, opts ...HandleFuncOption)
func HmacSha256Base64 ¶ added in v0.5.0
func Int64FromStr ¶
func IntFromStr ¶
func IsAjaxRequest ¶ added in v0.5.0
func MinifyHTML ¶ added in v0.5.0
func RSAPrivateKeyDecoded ¶ added in v0.6.0
func RSAPrivateKeyDecoded(privateKeyString string) (*rsa.PrivateKey, error)
func RSAPublicKeyDecoded ¶ added in v0.6.0
func RandomString ¶ added in v0.5.0
func ResponseContent ¶ added in v0.3.1
func ResponseContent(writer http.ResponseWriter, content, contentType, characterEncoding string)
func ResponseErrorContent ¶ added in v0.3.1
func ResponseErrorContent(writer http.ResponseWriter, statusCode int, errorContent, contentType, characterEncoding string)
func ResponseErrorHtml ¶ added in v0.3.1
func ResponseErrorHtml(writer http.ResponseWriter, statusCode int, html string)
func ResponseErrorJson ¶ added in v0.3.1
func ResponseErrorJson(writer http.ResponseWriter, statusCode int, json string)
func ResponseErrorText ¶ added in v0.3.1
func ResponseErrorText(writer http.ResponseWriter, statusCode int, text string)
func ResponseHtml ¶ added in v0.3.1
func ResponseHtml(writer http.ResponseWriter, html string)
func ResponseJson ¶ added in v0.3.1
func ResponseJson(writer http.ResponseWriter, json string)
func ResponseText ¶ added in v0.3.1
func ResponseText(writer http.ResponseWriter, text string)
func ReverseProxy ¶ added in v0.5.0
func ReverseProxy(target *url.URL) *httputil.ReverseProxy
func ServeAjax ¶ added in v0.5.0
func ServeAjax(handlerFunc http.HandlerFunc) http.HandlerFunc
func ServeGet ¶ added in v0.5.0
func ServeGet(handlerFunc http.HandlerFunc) http.HandlerFunc
func ServeMethod ¶ added in v0.5.0
func ServeMethod(handlerFunc http.HandlerFunc, httpMethods ...string) http.HandlerFunc
func ServeModelContext ¶ added in v0.5.0
func ServeModelContext(handlerFunc http.HandlerFunc) http.HandlerFunc
func ServeModelContextWithValueFunc ¶ added in v0.5.0
func ServeModelContextWithValueFunc(handlerFunc http.HandlerFunc, valueFunc ModelCtxValueFunc) http.HandlerFunc
func ServePost ¶ added in v0.5.0
func ServePost(handlerFunc http.HandlerFunc) http.HandlerFunc
func ServeRedirect ¶ added in v0.5.0
func ServeRedirect(redirect string) http.HandlerFunc
noinspection GoUnusedExportedFunction
func StrFromInt ¶
func StrFromInt64 ¶
func YamlRender ¶
YamlRender returns a string of the node as a YAML document. Note that Scalars will have a newline appended if they are rendered directly.
Types ¶
type CacheItem ¶
CacheItem is an individual cache item Parameter data contains the user-set value in the cache.
func NewCacheItem ¶
NewCacheItem returns a newly created CacheItem. Parameter key is the item's cache-key. Parameter lifeSpan determines after which time period without an access the item will get removed from the cache. Parameter data is the item's value.
func (*CacheItem) AccessCount ¶
AccessCount returns how often this item has been accessed.
func (*CacheItem) AccessedOn ¶
AccessedOn returns when this item was last accessed.
func (*CacheItem) Data ¶
func (item *CacheItem) Data() interface{}
Data returns the value of this cached item.
func (*CacheItem) KeepAlive ¶
func (item *CacheItem) KeepAlive()
KeepAlive marks an item to be kept for another expireDuration period. Ignored in ExpireAfterWrite cache
func (*CacheItem) Key ¶
func (item *CacheItem) Key() interface{}
Key returns the key of this cached item.
func (*CacheItem) SetAboutToExpireCallback ¶
func (item *CacheItem) SetAboutToExpireCallback(f func(interface{}))
SetAboutToExpireCallback configures a callback, which will be called right before the item is about to be removed from the cache.
type CacheItemPair ¶
type CacheItemPair struct { Key interface{} AccessCount int64 }
CacheItemPair maps key to access counter
type CacheItemPairList ¶
type CacheItemPairList []CacheItemPair
CacheItemPairList is a slice of CacheIemPairs that implements sort. Interface to sort by AccessCount.
func (CacheItemPairList) Len ¶
func (p CacheItemPairList) Len() int
func (CacheItemPairList) Less ¶
func (p CacheItemPairList) Less(i, j int) bool
func (CacheItemPairList) Swap ¶
func (p CacheItemPairList) Swap(i, j int)
type CacheTable ¶
CacheTable is a table within the cache
func CacheExpireAfterAccess ¶
func CacheExpireAfterAccess(table string) *CacheTable
noinspection GoUnusedExportedFunction
func CacheExpireAfterWrite ¶
func CacheExpireAfterWrite(table string) *CacheTable
noinspection GoUnusedExportedFunction
func NewCacheExpireAfterAccess ¶ added in v0.6.1
func NewCacheExpireAfterAccess(table string) *CacheTable
func NewCacheExpireAfterWrite ¶ added in v0.6.1
func NewCacheExpireAfterWrite(table string) *CacheTable
func (*CacheTable) Add ¶
func (table *CacheTable) Add(key interface{}, lifeSpan time.Duration, data interface{}) *CacheItem
Add adds a key/value pair to the cache. Parameter key is the item's cache-key. Parameter lifeSpan determines after which time period without an access the item will get removed from the cache. Parameter data is the item's value.
func (*CacheTable) Count ¶
func (table *CacheTable) Count() int
Count returns how many items are currently stored in the cache.
func (*CacheTable) Delete ¶
func (table *CacheTable) Delete(key interface{}) (*CacheItem, error)
Delete an item from the cache.
func (*CacheTable) Exists ¶
func (table *CacheTable) Exists(key interface{}) bool
Exists returns whether an item exists in the cache. Unlike the Value method Exists neither tries to fetch data via the loadData callback nor does it keep the item alive in the cache.
func (*CacheTable) Flush ¶
func (table *CacheTable) Flush()
Flush deletes all items from this cache table.
func (*CacheTable) Foreach ¶
func (table *CacheTable) Foreach(trans func(key interface{}, item *CacheItem))
Foreach all items
func (*CacheTable) LoadingAdd ¶
func (table *CacheTable) LoadingAdd(key interface{}, args ...interface{}) (*CacheItem, error)
func (*CacheTable) MostAccessed ¶
func (table *CacheTable) MostAccessed(count int64) []*CacheItem
MostAccessed returns the most accessed items in this cache table
func (*CacheTable) NotFoundAdd ¶
func (table *CacheTable) NotFoundAdd(key interface{}, lifeSpan time.Duration, data interface{}) bool
NotFoundAdd tests whether an item not found in the cache. Unlike the Exists method this also adds data if they key could not be found.
func (*CacheTable) SetAboutToDeleteItemCallback ¶
func (table *CacheTable) SetAboutToDeleteItemCallback(f func(*CacheItem))
SetAboutToDeleteItemCallback configures a callback, which will be called every time an item is about to be removed from the cache.
func (*CacheTable) SetAddedItemCallback ¶
func (table *CacheTable) SetAddedItemCallback(f func(*CacheItem))
SetAddedItemCallback configures a callback, which will be called every time a new item is added to the cache.
func (*CacheTable) SetDataLoader ¶
func (table *CacheTable) SetDataLoader(f func(interface{}, ...interface{}) (*CacheItem, error))
SetDataLoader configures a data-loader callback, which will be called when trying to access a non-existing key. The key and 0...n additional arguments are passed to the callback function.
func (*CacheTable) SetLogger ¶
func (table *CacheTable) SetLogger(logger *log.Logger)
SetLogger sets the logger to be used by this cache table.
func (*CacheTable) Value ¶
func (table *CacheTable) Value(key interface{}, args ...interface{}) (*CacheItem, error)
Value returns an item from the cache and marks it to be kept alive. You can pass additional arguments to your DataLoader callback function.
type Duration ¶ added in v0.6.2
func (*Duration) MarshalText ¶ added in v0.6.2
func (*Duration) UnmarshalText ¶ added in v0.6.2
type ExpireStrategy ¶
type ExpireStrategy int
type GzipResponseWriter ¶ added in v0.5.0
type GzipResponseWriter struct { io.Writer http.ResponseWriter }
type HandleFuncOption ¶ added in v0.5.0
type HandleFuncOption func(*HandleFuncOptions)
type HandleFuncOptions ¶ added in v0.5.0
type Hashset ¶ added in v0.4.1
type Hashset struct {
// contains filtered or unexported fields
}
func NewHashset ¶ added in v0.4.1
func NewHashset() *Hashset
type Hashtable ¶ added in v0.4.0
type Hashtable struct {
// contains filtered or unexported fields
}
func NewHashtable ¶ added in v0.4.0
func NewHashtable() *Hashtable
func (*Hashtable) Get ¶ added in v0.4.0
func (hashtable *Hashtable) Get(key interface{}) interface{}
func (*Hashtable) Put ¶ added in v0.4.0
func (hashtable *Hashtable) Put(key, value interface{}) interface{}
type HttpDownload ¶ added in v0.5.0
func NewHttpDownload ¶ added in v0.5.0
func NewHttpDownload(opts ...HttpDownloadOption) *HttpDownload
func (*HttpDownload) Start ¶ added in v0.5.0
func (download *HttpDownload) Start(opts ...HttpDownloadDelegateOption)
type HttpDownloadDelegate ¶ added in v0.5.0
type HttpDownloadDelegate struct { DownloadDidFailWithError func(*HttpDownload, error) DownloadDidStarted func(*HttpDownload) DownloadingWithProgress func(*HttpDownload, float64) DownloadingProgressInterval time.Duration DownloadDidFinish func(*HttpDownload) }
type HttpDownloadDelegateOption ¶ added in v0.5.0
type HttpDownloadDelegateOption func(*HttpDownloadDelegateOptions)
func WithDownloadDidFailWithError ¶ added in v0.5.0
func WithDownloadDidFailWithError(f func(*HttpDownload, error)) HttpDownloadDelegateOption
func WithDownloadDidFinish ¶ added in v0.5.0
func WithDownloadDidFinish(f func(*HttpDownload)) HttpDownloadDelegateOption
func WithDownloadDidStarted ¶ added in v0.5.0
func WithDownloadDidStarted(f func(*HttpDownload)) HttpDownloadDelegateOption
func WithDownloadingProgressInterval ¶ added in v0.5.1
func WithDownloadingProgressInterval(interval time.Duration) HttpDownloadDelegateOption
func WithDownloadingWithProgress ¶ added in v0.5.0
func WithDownloadingWithProgress(f func(*HttpDownload, float64)) HttpDownloadDelegateOption
type HttpDownloadDelegateOptions ¶ added in v0.5.0
type HttpDownloadDelegateOptions struct { DownloadDidFailWithError func(*HttpDownload, error) DownloadDidStarted func(*HttpDownload) DownloadingWithProgress func(*HttpDownload, float64) DownloadingProgressInterval time.Duration DownloadDidFinish func(*HttpDownload) }
type HttpDownloadOption ¶ added in v0.5.0
type HttpDownloadOption func(*HttpDownloadOptions)
func WithDstDir ¶ added in v0.5.0
func WithDstDir(dstDir string) HttpDownloadOption
func WithFileName ¶ added in v0.5.0
func WithFileName(fileName string) HttpDownloadOption
func WithOverWrite ¶ added in v0.5.0
func WithOverWrite(overWrite bool) HttpDownloadOption
func WithRawURL ¶ added in v0.5.0
func WithRawURL(rawURL string) HttpDownloadOption
type HttpDownloadOptions ¶ added in v0.5.0
type HttpReq ¶
type HttpReq struct {
// contains filtered or unexported fields
}
func NewHttpReq ¶
func (*HttpReq) ParamsMapping ¶
func (*HttpReq) RequestBody ¶
type HttpServerConfig ¶ added in v0.5.0
var GlobalHttpServerConfig *HttpServerConfig = nil
type LineReader ¶ added in v0.4.0
type LineReader struct {
// contains filtered or unexported fields
}
func NewLineReader ¶ added in v0.4.0
func NewLineReader(reader io.Reader) *LineReader
func (*LineReader) ReadLine ¶ added in v0.4.0
func (lineReader *LineReader) ReadLine() (int, error)
type LineReaderException ¶ added in v0.4.0
type LineReaderException struct {
Message string
}
func (*LineReaderException) Error ¶ added in v0.4.0
func (e *LineReaderException) Error() string
type ModelCtx ¶ added in v0.5.0
func ModelContext ¶ added in v0.5.0
func ModelContextWithValue ¶ added in v0.5.0
type ModelCtxValueFunc ¶ added in v0.5.0
type ModelCtxValueFunc func() (string, interface{})
type Properties ¶ added in v0.4.0
type Properties struct { Hashtable // contains filtered or unexported fields }
func NewProperties ¶ added in v0.4.0
func NewProperties(defaults ...*Properties) *Properties
func (*Properties) GetProperty ¶ added in v0.4.0
func (properties *Properties) GetProperty(key string) string
func (*Properties) GetPropertyDefault ¶ added in v0.4.0
func (properties *Properties) GetPropertyDefault(key, defaultValue string) string
func (*Properties) List ¶ added in v0.4.0
func (properties *Properties) List(out io.Writer)
func (*Properties) Load ¶ added in v0.4.0
func (properties *Properties) Load(reader io.Reader) error
func (*Properties) PropertyNames ¶ added in v0.4.0
func (properties *Properties) PropertyNames() []interface{}
func (*Properties) Save ¶ added in v0.4.0
func (properties *Properties) Save(writer io.Writer, comments string)
func (*Properties) SetProperty ¶ added in v0.4.0
func (properties *Properties) SetProperty(key string, value string)
func (*Properties) Store ¶ added in v0.4.0
func (properties *Properties) Store(writer io.Writer, comments string) error
func (*Properties) StringPropertyNames ¶ added in v0.4.0
func (properties *Properties) StringPropertyNames() []string
func (*Properties) ToMap ¶ added in v0.4.0
func (properties *Properties) ToMap() map[interface{}]interface{}
type RSAKeyPair ¶ added in v0.6.0
type RSAKeyPair struct { PrivateKey *rsa.PrivateKey PublicKey *rsa.PublicKey }
func GenerateRSAKeyPair ¶ added in v0.6.0
func GenerateRSAKeyPair(keySize int) (*RSAKeyPair, error)
func GenerateRSAKeyPairDefault ¶ added in v0.6.0
func GenerateRSAKeyPairDefault() (*RSAKeyPair, error)
func (*RSAKeyPair) RSAPrivateKeyEncoded ¶ added in v0.6.0
func (p *RSAKeyPair) RSAPrivateKeyEncoded() (string, error)
func (*RSAKeyPair) RSAPublicKeyEncoded ¶ added in v0.6.0
func (p *RSAKeyPair) RSAPublicKeyEncoded() (string, error)
type Signer ¶ added in v0.6.0
type Signer struct {
// contains filtered or unexported fields
}
func (*Signer) SignBase64ByRSAKey ¶ added in v0.6.0
func (*Signer) SignBase64ByRSAKeyString ¶ added in v0.6.0
func (*Signer) SignByRSAKey ¶ added in v0.6.0
func (*Signer) SignByRSAKeyString ¶ added in v0.6.0
func (*Signer) VerifyBase64ByRSAKey ¶ added in v0.6.0
func (*Signer) VerifyBase64ByRSAKeyString ¶ added in v0.6.0
func (*Signer) VerifyByRSAKey ¶ added in v0.6.0
type YamlFile ¶
type YamlFile struct {
Root YamlNode
}
A YamlFile represents the top-level YAML node found in a file. It is intended for use as a configuration file.
func ConfigYamlFile ¶
ConfigYamlFile reads a YAML configuration file from the given filename and panics if an error is found. This is a utility function and is intended for use in initializers. noinspection GoUnusedExportedFunction
func ConfigYamlString ¶
ConfigYamlString reads a YAML configuration from a static string. If an error is found, it will panic. This is a utility function and is intended for use in initializers. noinspection GoUnusedExportedFunction
func ReadYamlFile ¶
ReadYamlFile reads a YAML configuration file from the given filename.
func ReadYamlString ¶
func (*YamlFile) GetListCount ¶ added in v0.3.0
func (*YamlFile) RooListCount ¶ added in v0.3.0
func (*YamlFile) RootScalar ¶ added in v0.3.0
func (f *YamlFile) RootScalar() (YamlScalar, error)
func (*YamlFile) RootString ¶ added in v0.3.0
type YamlList ¶
type YamlList []YamlNode
A YamlList is a YAML Sequence of Nodes.
type YamlNode ¶
type YamlNode interface {
// contains filtered or unexported methods
}
A YamlNode is a YAML YamlNode which can be a YamlMap, YamlList or YamlScalar.
func YamlChild ¶
YamlChild retrieves a child node from the specified node as follows:
.mapkey - GetString the key 'mapkey' of the YamlNode, which must be a YamlMap [idx] - Choose the index from the current YamlNode, which must be a YamlList
The above selectors may be applied recursively, and each successive selector applies to the result of the previous selector. For convenience, a "." is implied as the first character if the first character is not a "." or "[". The node tree is walked from the given node, considering each token of the above format. If a node along the evaluation path is not found, an error is returned. If a node is not the proper type, an error is returned. If the final node is not a YamlScalar, an error is returned.
type YamlNodeNotFound ¶
func (*YamlNodeNotFound) Error ¶
func (e *YamlNodeNotFound) Error() string
type YamlNodeTypeMismatch ¶
type YamlNodeTypeMismatch struct { Full string Spec string Token string Node YamlNode Expected string }
func (*YamlNodeTypeMismatch) Error ¶
func (e *YamlNodeTypeMismatch) Error() string
type YamlScalar ¶
type YamlScalar string
A YamlScalar is a YAML YamlScalar.
func ScalarChild ¶ added in v0.3.0
func ScalarChild(root YamlNode, spec string) (YamlScalar, error)
func (YamlScalar) Bool ¶
func (node YamlScalar) Bool() (bool, error)
func (YamlScalar) Int ¶
func (node YamlScalar) Int() (int64, error)
func (YamlScalar) String ¶
func (node YamlScalar) String() (string, error)
String returns the string represented by this YamlScalar.
Notes ¶
Bugs ¶
Multi-line strings are currently not supported.
Source Files ¶
- boolean.go
- cache.go
- cache_errors.go
- cache_item.go
- cache_table.go
- collections.go
- cond.go
- hashset.go
- hashtable.go
- http.go
- httpdownload.go
- httpelf.go
- httpreq.go
- httpserver.go
- id.go
- ip.go
- json.go
- line_reader.go
- path.go
- properties.go
- random.go
- rsa.go
- secret.go
- strconv.go
- time.go
- yaml_config.go
- yaml_doc.go
- yaml_parser.go
- yaml_types.go
- ycomb.go