Documentation ¶
Index ¶
- Constants
- Variables
- func GetParam(r *http.Request, param string) string
- func GetParamByteSlice(r *http.Request, param string) ([]byte, error)
- func GetParamFloat64(r *http.Request, param string) (float64, error)
- func GetParamInt32(r *http.Request, param string) (int32, error)
- func GetParamInt64(r *http.Request, param string) (int64, error)
- func GetParamRegexp(r *http.Request, param string, re *regexp.Regexp) (string, error)
- func GetParamUint(r *http.Request, param string) (uint, error)
- func GetParamUint64(r *http.Request, param string) (uint64, error)
- func RecoverAndLogHandler(handler http.Handler) http.Handler
- func StartHTTPAndTLSServer(listenAddr string, handler http.Handler, certFile, keyFile string, ...) (listener net.Listener, err error)
- func StartHTTPServer(listenAddr string, handler http.Handler, config Config) (listener net.Listener, err error)
- func WriteRPCResponseHTTP(w http.ResponseWriter, res trtypes.RPCResponse)
- func WriteRPCResponseHTTPError(w http.ResponseWriter, httpCode int, res trtypes.RPCResponse)
- type Config
- type RequestHandler
- type ResponseWriterWrapper
Constants ¶
const ( // MaxBodyBytes controls the maximum number of bytes the // server will read parsing the request body. MaxBodyBytes = int64(1000000) // 1MB )
Variables ¶
var ( // RegexpInt 整数正则 RegexpInt = regexp.MustCompile(`^-?[0-9]+$`) // RegexpHex 16进制正则 RegexpHex = regexp.MustCompile(`^(?i)[a-f0-9]+$`) // RegexpEmail 正则 RegexpEmail = regexp.MustCompile(`^(?i)(` + dotAtom + `)@(` + dotAtom + `)$`) // RegexpAddress 正则 RegexpAddress = regexp.MustCompile(`^(?i)[a-z0-9]{25,34}$`) // RegexpHost 正则 RegexpHost = regexp.MustCompile(`^(?i)(` + domain + `)$`) )
Functions ¶
func GetParamByteSlice ¶
GetParamByteSlice 获取指定字节切片
func GetParamFloat64 ¶
GetParamFloat64 获取指定参数
func GetParamInt32 ¶
GetParamInt32 获取指定参数
func GetParamInt64 ¶
GetParamInt64 获取指定参数
func GetParamRegexp ¶
GetParamRegexp 获取指定参数
func GetParamUint ¶
GetParamUint 获取指定参数
func GetParamUint64 ¶
GetParamUint64 获取指定参数
func RecoverAndLogHandler ¶
RecoverAndLogHandler Wraps an HTTP handler, adding error logging. If the inner function panics, the outer function recovers, logs, sends an HTTP 500 error response.
func StartHTTPAndTLSServer ¶
func StartHTTPAndTLSServer( listenAddr string, handler http.Handler, certFile, keyFile string, config Config, ) (listener net.Listener, err error)
StartHTTPAndTLSServer starts an HTTPS server on listenAddr with the given handler. It wraps handler with RecoverAndLogHandler.
func StartHTTPServer ¶
func StartHTTPServer( listenAddr string, handler http.Handler, config Config, ) (listener net.Listener, err error)
StartHTTPServer starts an HTTP server on listenAddr with the given handler. It wraps handler with RecoverAndLogHandler.
func WriteRPCResponseHTTP ¶
func WriteRPCResponseHTTP(w http.ResponseWriter, res trtypes.RPCResponse)
WriteRPCResponseHTTP write rpc response
func WriteRPCResponseHTTPError ¶
func WriteRPCResponseHTTPError( w http.ResponseWriter, httpCode int, res trtypes.RPCResponse, )
WriteRPCResponseHTTPError write rpc response error
Types ¶
type RequestHandler ¶
type RequestHandler struct {
// contains filtered or unexported fields
}
RequestHandler handle rpc request
func NewRequestHandler ¶
func NewRequestHandler(h *tmtypes.EventBus, p *pool.TxPool) *RequestHandler
NewRequestHandler new a rpc request handler
func (RequestHandler) ABCIQuery ¶
func (s RequestHandler) ABCIQuery(path string, data cmn.HexBytes, height int64, trusted bool) (*ctypes.ResultABCIQuery, error)
ABCIQuery 交易、交易序号查询。
func (RequestHandler) BroadcastTxSync ¶
func (s RequestHandler) BroadcastTxSync(tx tmttypes.Tx) (*ctypes.ResultBroadcastTx, error)
BroadcastTxSync 广播交易。
func (RequestHandler) Health ¶
func (s RequestHandler) Health() (*ctypes.ResultHealth, error)
Health health check
type ResponseWriterWrapper ¶
type ResponseWriterWrapper struct { Status int http.ResponseWriter }
ResponseWriterWrapper Remember the status for logging
func (*ResponseWriterWrapper) Hijack ¶
func (w *ResponseWriterWrapper) Hijack() (net.Conn, *bufio.ReadWriter, error)
Hijack implements http.Hijacker
func (*ResponseWriterWrapper) WriteHeader ¶
func (w *ResponseWriterWrapper) WriteHeader(status int)
WriteHeader write header