httpx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleRaw

func HandleRaw(action rawAction) http.HandlerFunc

func NewHistoryMiddleware

func NewHistoryMiddleware(ledgerState *ledger.State, staleThreshold int32, session *db.Session) func(http.Handler) http.Handler

NewHistoryMiddleware adds session to the request context and ensures Horizon is not in a stale state, which is when the difference between latest core ledger and latest history ledger is higher than the given threshold

func WrapRaw

func WrapRaw(next http.Handler, action rawAction) http.Handler

Types

type ObjectActionHandler

type ObjectActionHandler struct {
	Action objectAction
}

func (ObjectActionHandler) ServeHTTP

func (handler ObjectActionHandler) ServeHTTP(
	w http.ResponseWriter,
	r *http.Request,
)

type Router

type Router struct {
	*chi.Mux
	Internal *chi.Mux
}

func NewRouter

func NewRouter(config *RouterConfig, serverMetrics *ServerMetrics, ledgerState *ledger.State) (*Router, error)

type RouterConfig

type RouterConfig struct {
	DBSession   *db.Session
	TxSubmitter *txsub.System
	RateQuota   *throttled.RateQuota

	SSEUpdateFrequency time.Duration
	StaleThreshold     uint
	ConnectionTimeout  time.Duration
	NetworkPassphrase  string
	MaxPathLength      uint
	PathFinder         paths.Finder
	PrometheusRegistry *prometheus.Registry
	CoreGetter         actions.CoreSettingsGetter
	HorizonVersion     string
	FriendbotURL       *url.URL
}

type Server

type Server struct {
	Router  *Router
	Metrics *ServerMetrics
	// contains filtered or unexported fields
}

Server contains the http server related fields for horizon: the Router, rate limiter, etc.

func NewServer

func NewServer(serverConfig ServerConfig, routerConfig RouterConfig, ledgerState *ledger.State) (*Server, error)

func (*Server) Serve

func (s *Server) Serve() error

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

type ServerConfig

type ServerConfig struct {
	Port      uint16
	TLSConfig *TLSConfig
	AdminPort uint16
}

type ServerMetrics

type ServerMetrics struct {
	RequestDurationSummary *prometheus.SummaryVec
}

type StateMiddleware

type StateMiddleware struct {
	HorizonSession      *db.Session
	NoStateVerification bool
}

StateMiddleware is a middleware which enables a state handler if the state has been initialized. Unless NoStateVerification is set, it ensures that the state (ledger entries) has been verified and is correct (Otherwise returns `500 Internal Server Error` to prevent returning invalid data to the user)

func (*StateMiddleware) Wrap

WrapFunc executes the middleware on a given HTTP handler function

func (*StateMiddleware) WrapFunc

WrapFunc executes the middleware on a given HTTP handler function

type TLSConfig

type TLSConfig struct {
	CertPath, KeyPath string
}

type VaryByRemoteIP

type VaryByRemoteIP struct{}

func (VaryByRemoteIP) Key

func (v VaryByRemoteIP) Key(r *http.Request) string

Jump to

Keyboard shortcuts

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