Documentation
¶
Index ¶
- Constants
- Variables
- func AddQueryValue(b, s string) string
- func CacheKey(key string, s ...string) string
- func CacheKeyFromRequest(r *http.Request) string
- func CacheKeyPath(r *http.Request) string
- func DefaultItemsLimiter(string) int64
- func HTTP2HandleError(w http.ResponseWriter, err error)
- func HTTP2NotSupported(w http.ResponseWriter, err error)
- func HTTP2ProblemWithError(w http.ResponseWriter, err error, status int)
- func HTTP2Stream(enc encoder.Encoder, w http.ResponseWriter, bufsize int, status int) (*jsoniter.Stream, func())
- func HTTP2WriteBytes(w http.ResponseWriter, b []byte, contentType string, status int)
- func HTTP2WriteCache(w http.ResponseWriter, key string, expire time.Duration)
- func HTTP2WriteHal(enc encoder.Encoder, w http.ResponseWriter, hal Hal, status int)
- func HTTP2WriteHalBytes(enc encoder.Encoder, w http.ResponseWriter, b []byte, status int)
- func HTTP2WriteProblem(w http.ResponseWriter, pr Problem, status int)
- func HandleAccount(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleAccountOperations(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleAccounts(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleBlock(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleCurrencies(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleCurrency(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleDIDData(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleDIDDesign(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleDIDDocument(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleManifestByHash(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleManifestByHeight(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleManifests(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleNodeInfo(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleNodeInfoProm(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleNodeMetric(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleNodeMetricProm(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleOperation(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleOperations(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleOperationsByHash(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleOperationsByHeight(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleQueueSend(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func HandleSend(hd *Handlers, w http.ResponseWriter, r *http.Request)
- func LoadFromCache(cache Cache, key string, w http.ResponseWriter) error
- func MakeCacheKey(key string) string
- func NodeInfo(client *isaacnetwork.BaseClient, connInfo quicstream.ConnInfo) (*isaacnetwork.NodeInfo, error)
- func NodeMetric(client *isaacnetwork.BaseClient, connInfo quicstream.ConnInfo) (*isaacnetwork.NodeMetrics, error)
- func ParseBoolQuery(s string) bool
- func ParseCSVStringQuery(s string) []string
- func ParseLimitQuery(s string) int64
- func ParseRequest(_ http.ResponseWriter, r *http.Request, v string) (string, error, int)
- func ParseStringQuery(s string) string
- func ProcessAPI(ctx context.Context) (context.Context, error)
- func ProcessStartAPI(ctx context.Context) (context.Context, error)
- func RateLimiter(rps int, burst int) func(http.Handler) http.Handler
- func ScanCRLF(data []byte, atEOF bool) (int, []byte, error)
- func SetHandlers(hd *Handlers, digest bool)
- func StringBoolQuery(key string, v bool) string
- func StringOffsetQuery(offset string) string
- func WriteFromCache(b []byte, w http.ResponseWriter) error
- type BaseHal
- func (hal BaseHal) AddExtras(key string, value interface{}) Hal
- func (hal BaseHal) AddLink(rel string, link HalLink) Hal
- func (hal BaseHal) Extras() map[string]interface{}
- func (hal BaseHal) Interface() interface{}
- func (hal BaseHal) Links() map[string]HalLink
- func (hal BaseHal) MarshalJSON() ([]byte, error)
- func (hal BaseHal) RawInterface() []byte
- func (hal BaseHal) Self() HalLink
- func (hal BaseHal) SetInterface(i interface{}) Hal
- func (hal BaseHal) SetSelf(u HalLink) Hal
- func (hal *BaseHal) UnmarshalJSON(b []byte) error
- type BaseHalJSONMarshaler
- type BaseHalJSONUnpacker
- type Cache
- type CacheResponseWriter
- func (cr *CacheResponseWriter) Cache() error
- func (cr *CacheResponseWriter) Expire() time.Duration
- func (cr *CacheResponseWriter) Key() string
- func (cr *CacheResponseWriter) OK() bool
- func (cr *CacheResponseWriter) SetExpire(expire time.Duration) *CacheResponseWriter
- func (cr *CacheResponseWriter) SetKey(key string) *CacheResponseWriter
- func (cr *CacheResponseWriter) SkipCache() *CacheResponseWriter
- func (cr *CacheResponseWriter) Write(b []byte) (int, error)
- func (cr *CacheResponseWriter) WriteHeader(status int)
- type CachedHTTPHandler
- type DummyCache
- type HTTP2Server
- func (sv *HTTP2Server) HandleRequest(wrapper RequestWrapper)
- func (sv *HTTP2Server) Initialize() error
- func (sv *HTTP2Server) Queue() chan RequestWrapper
- func (sv *HTTP2Server) Router() *mux.Router
- func (sv *HTTP2Server) SetEncoder(encs *encoder.Encoders)
- func (sv *HTTP2Server) SetNetworkClientFunc(...) *HTTP2Server
- func (sv *HTTP2Server) SetRouter(router *mux.Router)
- type Hal
- type HalLink
- func (hl HalLink) Href() string
- func (hl HalLink) MarshalJSON() ([]byte, error)
- func (hl HalLink) Properties() map[string]interface{}
- func (hl HalLink) SetProperty(key string, value interface{}) HalLink
- func (hl HalLink) SetTemplated() HalLink
- func (hl HalLink) URL() (*url.URL, error)
- func (hl *HalLink) UnmarshalJSON(b []byte) error
- type HalLinkJSONUnpacker
- type HandlerFunc
- type Handlers
- func (hd *Handlers) Cache() Cache
- func (hd *Handlers) CombineURL(path string, pairs ...string) (string, error)
- func (hd *Handlers) Database() *digest.Database
- func (hd *Handlers) Encoder() encoder.Encoder
- func (hd *Handlers) Encoders() *encoder.Encoders
- func (hd *Handlers) ExpireLongLived() time.Duration
- func (hd *Handlers) ExpireNotFilled() time.Duration
- func (hd *Handlers) ExpireShortLived() time.Duration
- func (hd *Handlers) Handler() http.Handler
- func (hd *Handlers) Initialize() error
- func (hd *Handlers) RG() *singleflight.Group
- func (hd *Handlers) Router() *mux.Router
- func (hd *Handlers) Routes() map[string]*mux.Route
- func (hd *Handlers) SetEncoder(encoder encoder.Encoder)
- func (hd *Handlers) SetEncoders(encoders *encoder.Encoders)
- func (hd *Handlers) SetHandler(prefix string, h HandlerFunc, useCache bool, rps, burst int) *mux.Route
- func (hd *Handlers) SetLimiter(f func(string) int64) *Handlers
- func (hd *Handlers) SetNetworkClientFunc(...) *Handlers
- type LocalMemCache
- type Memcached
- type Problem
- type RequestWrapper
Constants ¶
View Source
const ( ExpireFilled = time.Second * 3 ExpireShortLived = time.Millisecond * 100 ExpireLongLived = time.Hour * 3000 )
View Source
const ( ProblemMimetype = "application/problem+json; charset=utf-8" ProblemNamespace = "https://github.com/ProtoconNet/mitum-currency/v3/problems" DefaultProblemType = "others" )
Variables ¶
View Source
var ( DefaultCacheExpire = time.Hour SkipCacheError = util.NewIDError("skip cache") )
View Source
var ( HTTP2EncoderHintHeader = http.CanonicalHeaderKey("x-mitum-encoder-hint") HALMimetype = "application/hal+json; charset=utf-8" PlainTextMimetype = "text/plain; charset=utf-8" PrometheusTextMimetype = "text/plain; version=0.0.4" )
View Source
var ( HandlerPathNodeInfo = `/` HandlerPathNodeInfoProm = `/info/prom` HandlerPathNodeMetric = `/metrics` HandlerPathNodeMetricProm = `/metrics/prom` HandlerPathCurrencies = `/currency` HandlerPathCurrency = `/currency/{currency_id:` + types.ReCurrencyID + `}` HandlerPathManifests = `/block/manifests` HandlerPathOperations = `/block/operations` HandlerPathOperationsByHash = `/block/operations/facts` HandlerPathOperation = `/block/operation/{hash:(?i)[0-9a-z][0-9a-z]+}` HandlerPathBlockByHeight = `/block/{height:[0-9]+}` HandlerPathBlockByHash = `/block/{hash:(?i)[0-9a-z][0-9a-z]+}` HandlerPathOperationsByHeight = `/block/{height:[0-9]+}/operations` HandlerPathManifestByHeight = `/block/{height:[0-9]+}/manifest` HandlerPathManifestByHash = `/block/{hash:(?i)[0-9a-z][0-9a-z]+}/manifest` HandlerPathAccount = `/account/{address:(?i)` + types.REStringAddressString + `}` // revive:disable-line:line-length-limit HandlerPathAccountOperations = `/account/{address:(?i)` + types.REStringAddressString + `}/operations` // revive:disable-line:line-length-limit HandlerPathAccounts = `/accounts` HandlerPathOperationBuildFactTemplate = `/builder/operation/fact/template/{fact:[\w][\w\-]*}` HandlerPathOperationBuildFact = `/builder/operation/fact` HandlerPathOperationBuildSign = `/builder/operation/sign` HandlerPathOperationBuild = `/builder/operation` HandlerPathSend = `/builder/send` HandlerPathQueueSend = `/builder/send/queue` HandelrPathEventOperation = `/event/operation/{hash:(?i)[0-9a-z][0-9a-z]+}` HandelrPathEventAccount = `/event/account/{address:(?i)` + types.REStringAddressString + `}` HandlerPathEventContract = `/event/contract/{address:(?i)` + types.REStringAddressString + `}` )
View Source
var ( UnknownProblem = NewProblem(DefaultProblemType, "unknown problem occurred") UnknownProblemJSON []byte )
View Source
var ( HandlerPathDIDDesign = `/did-registry/{contract:(?i)` + types.REStringAddressString + `}` HandlerPathDIDData = `/did-registry/{contract:(?i)` + types.REStringAddressString + `}/did/{method_specific_id:` + types.ReSpecialCh + `}` HandlerPathDIDDocument = `/did-registry/{contract:(?i)` + types.REStringAddressString + `}/document` )
View Source
var (
BaseHalHint = hint.MustNewHint("mitum-currency-hal-v0.0.1")
)
View Source
var ContextValueDigestNetwork util.ContextKey = "digest_network"
View Source
var GlobalItemsLimit int64 = 10
View Source
var HALJSONConfigDefault = jsoniter.Config{ EscapeHTML: false, }.Froze()
View Source
var PNameAPI = ps.Name("api")
View Source
var PNameStartAPI = ps.Name("start_api")
View Source
var (
ProblemHint = hint.MustNewHint("mitum-currency-problem-v0.0.1")
)
Functions ¶
func AddQueryValue ¶
func CacheKeyFromRequest ¶
func CacheKeyPath ¶
func DefaultItemsLimiter ¶
func HTTP2HandleError ¶
func HTTP2HandleError(w http.ResponseWriter, err error)
func HTTP2NotSupported ¶
func HTTP2NotSupported(w http.ResponseWriter, err error)
func HTTP2ProblemWithError ¶
func HTTP2ProblemWithError(w http.ResponseWriter, err error, status int)
func HTTP2Stream ¶
func HTTP2WriteBytes ¶
func HTTP2WriteBytes(w http.ResponseWriter, b []byte, contentType string, status int)
func HTTP2WriteCache ¶
func HTTP2WriteCache(w http.ResponseWriter, key string, expire time.Duration)
func HTTP2WriteHal ¶
func HTTP2WriteHalBytes ¶
func HTTP2WriteProblem ¶
func HTTP2WriteProblem(w http.ResponseWriter, pr Problem, status int)
func HandleAccount ¶
func HandleAccount(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleAccountOperations ¶
func HandleAccountOperations(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleAccounts ¶
func HandleAccounts(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleBlock ¶
func HandleBlock(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleCurrencies ¶
func HandleCurrencies(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleCurrency ¶
func HandleCurrency(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleDIDData ¶
func HandleDIDData(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleDIDDesign ¶
func HandleDIDDesign(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleDIDDocument ¶
func HandleDIDDocument(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleManifestByHash ¶
func HandleManifestByHash(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleManifestByHeight ¶
func HandleManifestByHeight(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleManifests ¶
func HandleManifests(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleNodeInfo ¶
func HandleNodeInfo(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleNodeInfoProm ¶
func HandleNodeInfoProm(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleNodeMetric ¶
func HandleNodeMetric(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleNodeMetricProm ¶
func HandleNodeMetricProm(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleOperation ¶
func HandleOperation(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleOperations ¶
func HandleOperations(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleOperationsByHash ¶
func HandleOperationsByHash(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleOperationsByHeight ¶
func HandleOperationsByHeight(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleQueueSend ¶
func HandleQueueSend(hd *Handlers, w http.ResponseWriter, r *http.Request)
func HandleSend ¶
func HandleSend(hd *Handlers, w http.ResponseWriter, r *http.Request)
func LoadFromCache ¶
func LoadFromCache(cache Cache, key string, w http.ResponseWriter) error
func MakeCacheKey ¶
func NodeInfo ¶
func NodeInfo(client *isaacnetwork.BaseClient, connInfo quicstream.ConnInfo) (*isaacnetwork.NodeInfo, error)
func NodeMetric ¶
func NodeMetric(client *isaacnetwork.BaseClient, connInfo quicstream.ConnInfo) (*isaacnetwork.NodeMetrics, error)
func ParseBoolQuery ¶
func ParseCSVStringQuery ¶
func ParseLimitQuery ¶
func ParseRequest ¶
func ParseStringQuery ¶
func SetHandlers ¶
func StringBoolQuery ¶
func StringOffsetQuery ¶
func WriteFromCache ¶
func WriteFromCache(b []byte, w http.ResponseWriter) error
Types ¶
type BaseHal ¶
type BaseHal struct {
hint.BaseHinter
// contains filtered or unexported fields
}
func NewBaseHal ¶
func NewEmptyHal ¶
func NewEmptyHal() BaseHal
func (BaseHal) MarshalJSON ¶
func (BaseHal) RawInterface ¶
func (BaseHal) SetInterface ¶
func (*BaseHal) UnmarshalJSON ¶
type BaseHalJSONMarshaler ¶
type BaseHalJSONMarshaler struct {
hint.BaseHinter
Embedded interface{} `json:"_embedded,omitempty"`
Links map[string]HalLink `json:"_links,omitempty"`
Extra map[string]interface{} `json:"_extra,omitempty"`
}
type BaseHalJSONUnpacker ¶
type BaseHalJSONUnpacker struct {
Embedded json.RawMessage `json:"_embedded,omitempty"`
Links map[string]HalLink `json:"_links,omitempty"`
Extra map[string]interface{} `json:"_extra,omitempty"`
}
type Cache ¶
func NewCacheFromURI ¶
type CacheResponseWriter ¶
type CacheResponseWriter struct {
http.ResponseWriter
// contains filtered or unexported fields
}
func NewCacheResponseWriter ¶
func NewCacheResponseWriter(cache Cache, w http.ResponseWriter, r *http.Request) *CacheResponseWriter
func (*CacheResponseWriter) Cache ¶
func (cr *CacheResponseWriter) Cache() error
func (*CacheResponseWriter) Expire ¶
func (cr *CacheResponseWriter) Expire() time.Duration
func (*CacheResponseWriter) Key ¶
func (cr *CacheResponseWriter) Key() string
func (*CacheResponseWriter) OK ¶
func (cr *CacheResponseWriter) OK() bool
func (*CacheResponseWriter) SetExpire ¶
func (cr *CacheResponseWriter) SetExpire(expire time.Duration) *CacheResponseWriter
func (*CacheResponseWriter) SetKey ¶
func (cr *CacheResponseWriter) SetKey(key string) *CacheResponseWriter
func (*CacheResponseWriter) SkipCache ¶
func (cr *CacheResponseWriter) SkipCache() *CacheResponseWriter
func (*CacheResponseWriter) WriteHeader ¶
func (cr *CacheResponseWriter) WriteHeader(status int)
type CachedHTTPHandler ¶
func NewCachedHTTPHandler ¶
func NewCachedHTTPHandler(cache Cache, f func(http.ResponseWriter, *http.Request)) CachedHTTPHandler
func (CachedHTTPHandler) ServeHTTP ¶
func (ch CachedHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type DummyCache ¶
type DummyCache struct{}
type HTTP2Server ¶
type HTTP2Server struct {
sync.RWMutex
*logging.Logging
*util.ContextDaemon
// contains filtered or unexported fields
}
func NewHTTP2Server ¶
func NewHTTP2Server( bind, host string, certs []tls.Certificate, encs *encoder.Encoders, networkID base.NetworkID, ) (*HTTP2Server, error)
func (*HTTP2Server) HandleRequest ¶
func (sv *HTTP2Server) HandleRequest(wrapper RequestWrapper)
func (*HTTP2Server) Initialize ¶
func (sv *HTTP2Server) Initialize() error
func (*HTTP2Server) Queue ¶
func (sv *HTTP2Server) Queue() chan RequestWrapper
func (*HTTP2Server) Router ¶
func (sv *HTTP2Server) Router() *mux.Router
func (*HTTP2Server) SetEncoder ¶
func (sv *HTTP2Server) SetEncoder(encs *encoder.Encoders)
func (*HTTP2Server) SetNetworkClientFunc ¶
func (sv *HTTP2Server) SetNetworkClientFunc(f func() (*isaacnetwork.BaseClient, *quicmemberlist.Memberlist, []quicstream.ConnInfo, error)) *HTTP2Server
func (*HTTP2Server) SetRouter ¶
func (sv *HTTP2Server) SetRouter(router *mux.Router)
type HalLink ¶
type HalLink struct {
// contains filtered or unexported fields
}
func NewHalLink ¶
func (HalLink) MarshalJSON ¶
func (HalLink) Properties ¶
func (HalLink) SetProperty ¶
func (HalLink) SetTemplated ¶
func (*HalLink) UnmarshalJSON ¶
type HalLinkJSONUnpacker ¶
type HandlerFunc ¶
type HandlerFunc func(*Handlers, http.ResponseWriter, *http.Request)
type Handlers ¶
type Handlers struct {
*zerolog.Logger
ItemsLimiter func(string) int64
// contains filtered or unexported fields
}
func NewHandlers ¶
func (*Handlers) CombineURL ¶
func (*Handlers) ExpireLongLived ¶
func (*Handlers) ExpireNotFilled ¶
func (*Handlers) ExpireShortLived ¶
func (*Handlers) Initialize ¶
func (*Handlers) RG ¶
func (hd *Handlers) RG() *singleflight.Group
func (*Handlers) SetEncoder ¶
func (*Handlers) SetEncoders ¶
func (*Handlers) SetHandler ¶
func (*Handlers) SetNetworkClientFunc ¶
func (hd *Handlers) SetNetworkClientFunc(f func() (*quicstream.ConnectionPool, *quicmemberlist.Memberlist, []quicstream.ConnInfo, error)) *Handlers
type LocalMemCache ¶
type LocalMemCache struct {
// contains filtered or unexported fields
}
func NewLocalMemCache ¶
func NewLocalMemCache(size int, expire time.Duration) *LocalMemCache
type Memcached ¶
type Memcached struct {
// contains filtered or unexported fields
}
func NewMemcached ¶
type Problem ¶
type Problem struct {
// contains filtered or unexported fields
}
Problem implements "Problem Details for HTTP APIs"<https://tools.ietf.org/html/rfc7807>.
func NewProblem ¶
func NewProblemFromError ¶
type RequestWrapper ¶
type RequestWrapper struct {
// contains filtered or unexported fields
}
Source Files
¶
- cache.go
- context.go
- hal.go
- hal_json.go
- handler.go
- handler_account.go
- handler_block.go
- handler_currency.go
- handler_did_registry.go
- handler_event.go
- handler_manifest.go
- handler_no_dev_tag.go
- handler_node_info.go
- handler_node_metric.go
- handler_operation.go
- handler_send.go
- problem.go
- process_api.go
- server.go
- set_networkclient.go
- util.go
Click to show internal directories.
Click to hide internal directories.