Documentation
¶
Overview ¶
Package server is a generated GoMock package.
Index ¶
- Constants
- func Authorize(ctx context.Context, op zip.Op, _ any) error
- func Chain(uri, alias string) string
- func Mount(app *zip.App) (http.Handler, error)
- func Open(op zip.Op) bool
- func TraceHandler(h http.Handler, name string, tracer trace.Tracer) http.Handler
- type HTTPConfig
- type MockServer
- func (m *MockServer) AddAliases(arg0 string, arg1 ...string) error
- func (m *MockServer) AddAliasesWithReadLock(arg0 string, arg1 ...string) error
- func (m *MockServer) AddRoute(arg0 http.Handler, arg1, arg2 string) error
- func (m *MockServer) AddRouteWithReadLock(arg0 http.Handler, arg1, arg2 string) error
- func (m *MockServer) Dispatch() error
- func (m *MockServer) EXPECT() *MockServerMockRecorder
- func (m *MockServer) RegisterChain(arg0 string, arg1 *runtime.Runtime, arg2 vm.VM)
- func (m *MockServer) Shutdown() error
- type MockServerMockRecorder
- func (mr *MockServerMockRecorder) AddAliases(arg0 any, arg1 ...any) *gomock.Call
- func (mr *MockServerMockRecorder) AddAliasesWithReadLock(arg0 any, arg1 ...any) *gomock.Call
- func (mr *MockServerMockRecorder) AddRoute(arg0, arg1, arg2 any) *gomock.Call
- func (mr *MockServerMockRecorder) AddRouteWithReadLock(arg0, arg1, arg2 any) *gomock.Call
- func (mr *MockServerMockRecorder) Dispatch() *gomock.Call
- func (mr *MockServerMockRecorder) RegisterChain(arg0, arg1, arg2 any) *gomock.Call
- func (mr *MockServerMockRecorder) Shutdown() *gomock.Call
- type PathAdder
- type PathAdderWithReadLock
- type RootInfo
- type RootInfoProvider
- type Server
- type StateGetter
- type Wrapper
Constants ¶
const HTTPHeaderRoute = apitypes.HTTPHeaderRoute
const Ops = "/ops"
Ops is the endpoint an app of typed operations is mounted at, beneath the base its service already answers on: /v1/info/ops, /v1/chain/P/ops.
It is an endpoint rather than the base itself because [router.forceAddRouter] records a prefix mount ONLY for a non-empty endpoint — a handler at the base owns that exact path and nothing beneath it, so an app mounted there would serve neither its operations nor its document. One name for it, here, so every service on the node is reachable the same way.
const Refused = "this changes the node, and a node answers to its operator"
Refused is the stem of every refusal this rule speaks. Exported because a test has to tell it from the other 403s an operation can meet — a suite that only asked whether something refused would pass with this control deleted.
const Relay = "/tx"
Relay is the address at which a chain accepts a write from anyone: already signed transaction bytes, forwarded to consensus. The node checks no signature there because it holds no key that could have made one — the bytes carry their own authority.
One address, deliberately. An operation that takes signed bytes and is registered anywhere else meets Refused, which is a loud wrong answer rather than a quiet open door.
Variables ¶
This section is empty.
Functions ¶
func Authorize ¶ added in v1.36.178
Authorize is the node's one authorization decision, run at the invoke seam of every typed op on every mounted app. Mount installs it; nothing else needs to, and nothing else should.
func Chain ¶ added in v1.36.179
Chain is where a chain answers, and the one place that address is built.
uri is a node's base URL, or empty for a path on this node: Chain("", "P")+Ops is /v1/chain/P/ops. The segment is constants.ChainAliasPrefix, named once, so every caller moves with it. That is the point of routing them all through here: when the segment last changed, the clients that spelled it by hand went on pointing at the name the router had already left behind.
func Mount ¶ added in v1.36.178
Mount serves app and hands back its net/http face, ready for AddRoute.
It installs Authorize before it serves, and the ordering is the whole point. zip raises an MCP door on any app holding a typed op, and an app with no Authorizer answers whoever knocks — so a mount that had to REMEMBER to authorize would eventually be a mount that forgot. Here, forgetting means not mounting: this is the only verb that puts a zip app on the node's router, so every app on it is under the rule by construction rather than by review.
Types ¶
type HTTPConfig ¶
type MockServer ¶
type MockServer struct {
// contains filtered or unexported fields
}
MockServer is a mock of Server interface.
func NewMockServer ¶
func NewMockServer(ctrl *gomock.Controller) *MockServer
NewMockServer creates a new mock instance.
func (*MockServer) AddAliases ¶
func (m *MockServer) AddAliases(arg0 string, arg1 ...string) error
AddAliases mocks base method.
func (*MockServer) AddAliasesWithReadLock ¶
func (m *MockServer) AddAliasesWithReadLock(arg0 string, arg1 ...string) error
AddAliasesWithReadLock mocks base method.
func (*MockServer) AddRoute ¶
func (m *MockServer) AddRoute(arg0 http.Handler, arg1, arg2 string) error
AddRoute mocks base method.
func (*MockServer) AddRouteWithReadLock ¶
func (m *MockServer) AddRouteWithReadLock(arg0 http.Handler, arg1, arg2 string) error
AddRouteWithReadLock mocks base method.
func (*MockServer) EXPECT ¶
func (m *MockServer) EXPECT() *MockServerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockServer) RegisterChain ¶
RegisterChain mocks base method.
type MockServerMockRecorder ¶
type MockServerMockRecorder struct {
// contains filtered or unexported fields
}
MockServerMockRecorder is the mock recorder for MockServer.
func (*MockServerMockRecorder) AddAliases ¶
func (mr *MockServerMockRecorder) AddAliases(arg0 any, arg1 ...any) *gomock.Call
AddAliases indicates an expected call of AddAliases.
func (*MockServerMockRecorder) AddAliasesWithReadLock ¶
func (mr *MockServerMockRecorder) AddAliasesWithReadLock(arg0 any, arg1 ...any) *gomock.Call
AddAliasesWithReadLock indicates an expected call of AddAliasesWithReadLock.
func (*MockServerMockRecorder) AddRoute ¶
func (mr *MockServerMockRecorder) AddRoute(arg0, arg1, arg2 any) *gomock.Call
AddRoute indicates an expected call of AddRoute.
func (*MockServerMockRecorder) AddRouteWithReadLock ¶
func (mr *MockServerMockRecorder) AddRouteWithReadLock(arg0, arg1, arg2 any) *gomock.Call
AddRouteWithReadLock indicates an expected call of AddRouteWithReadLock.
func (*MockServerMockRecorder) Dispatch ¶
func (mr *MockServerMockRecorder) Dispatch() *gomock.Call
Dispatch indicates an expected call of Dispatch.
func (*MockServerMockRecorder) RegisterChain ¶
func (mr *MockServerMockRecorder) RegisterChain(arg0, arg1, arg2 any) *gomock.Call
RegisterChain indicates an expected call of RegisterChain.
func (*MockServerMockRecorder) Shutdown ¶
func (mr *MockServerMockRecorder) Shutdown() *gomock.Call
Shutdown indicates an expected call of Shutdown.
type PathAdder ¶
type PathAdder interface {
// AddRoute registers a route to a handler.
AddRoute(handler http.Handler, base, endpoint string) error
// AddAliases registers aliases to the server
AddAliases(endpoint string, aliases ...string) error
}
func PathWriterFromWithReadLock ¶
func PathWriterFromWithReadLock(pather PathAdderWithReadLock) PathAdder
type PathAdderWithReadLock ¶
type PathAdderWithReadLock interface {
// AddRouteWithReadLock registers a route to a handler assuming the http
// read lock is currently held.
AddRouteWithReadLock(handler http.Handler, base, endpoint string) error
// AddAliasesWithReadLock registers aliases to the server assuming the http read
// lock is currently held.
AddAliasesWithReadLock(endpoint string, aliases ...string) error
}
type RootInfo ¶ added in v1.23.5
type RootInfo struct {
NodeID string `json:"nodeId,omitempty"`
NetworkID uint32 `json:"networkId,omitempty"`
Version string `json:"version,omitempty"`
Ready bool `json:"ready"`
Chains struct {
C string `json:"c"`
P string `json:"p"`
X string `json:"x"`
} `json:"chains"`
Endpoints struct {
RPC string `json:"rpc"`
Websocket string `json:"ws"`
Info string `json:"info"`
Health string `json:"health"`
} `json:"endpoints"`
}
RootInfo contains information returned at the root endpoint
type RootInfoProvider ¶ added in v1.23.5
type RootInfoProvider interface {
GetRootInfo() RootInfo
}
RootInfoProvider provides node information for the root endpoint
type Server ¶
type Server interface {
PathAdder
PathAdderWithReadLock
// Dispatch starts the API server
Dispatch() error
// RegisterChain registers the API endpoints associated with this chain.
// That is, add <route, handler> pairs to server so that API calls can be
// made to the VM.
RegisterChain(chainName string, rt *runtime.Runtime, vm vm.VM)
// Shutdown this server
Shutdown() error
// SetRootInfoProvider sets the provider for root endpoint information
SetRootInfoProvider(provider RootInfoProvider)
}
Server maintains the HTTP router
func New ¶
func New( log log.Logger, listener net.Listener, allowedOrigins []string, shutdownTimeout time.Duration, nodeID ids.NodeID, tracingEnabled bool, tracer trace.Tracer, registerer metric.Registerer, httpConfig HTTPConfig, allowedHosts []string, ) (Server, error)
New returns an instance of a Server.
type StateGetter ¶
StateGetter interface for getting chain state
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package servermock is a generated GoMock package.
|
Package servermock is a generated GoMock package. |