snroute

package
v1.24.2-dev Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Writer  http.ResponseWriter
	Request *http.Request
	// contains filtered or unexported fields
}

Context is the request view available to Open and Read handlers. It has no method that returns a submitting transactor.

func (Context) Command

func (c Context) Command() *cli.Command

Command is the daemon CLI command used to load services.

type OpenRoute

type OpenRoute struct {
	// contains filtered or unexported fields
}

OpenRoute never requires a bearer token (health checks).

func Open

func Open(path string, h func(Context)) OpenRoute

Open returns a route that never requires a bearer token.

func (OpenRoute) Path

func (r OpenRoute) Path() string

func (OpenRoute) RegisterTo

func (r OpenRoute) RegisterTo(router *Router)

RegisterTo adds the route to router. Handle remains the primitive that applies auth; this is the one-line registration used in routes.go files.

func (OpenRoute) RequiresToken

func (OpenRoute) RequiresToken(bool) bool

type ReadRoute

type ReadRoute struct {
	// contains filtered or unexported fields
}

ReadRoute requires a token only when Token Scope is "all endpoints".

func Read

func Read(path string, h func(Context)) ReadRoute

Read returns a route that requires a token only when Token Scope is all endpoints.

func (ReadRoute) Path

func (r ReadRoute) Path() string

func (ReadRoute) RegisterTo

func (r ReadRoute) RegisterTo(router *Router)

func (ReadRoute) RequiresToken

func (ReadRoute) RequiresToken(unauthenticatedReads bool) bool

type Route

type Route interface {
	Path() string
	RequiresToken(sensitiveOnly bool) bool
	// contains filtered or unexported methods
}

Route is an HTTP endpoint bound to a path with a compile-time auth class.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router registers typed routes and applies per-route bearer auth.

func NewRouter

func NewRouter(cmd *cli.Command, tokens []apitoken.Record, unauthenticatedReads bool) *Router

NewRouter returns a router that authenticates against tokens. unauthenticatedReads allows Read routes without a bearer token; Write routes always require a write-scoped token.

func (*Router) Handle

func (r *Router) Handle(rt Route)

Handle registers rt. Auth is applied here so a Write route cannot be registered without a token check.

func (*Router) Routes

func (r *Router) Routes() []Route

Routes returns registered routes in registration order.

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

type TransactOpts

type TransactOpts struct {
	// contains filtered or unexported fields
}

TransactOpts is a node-account transactor for submitting a transaction. The only constructor is WriteContext.Transactor; the inner opts are unexported so a Read handler cannot forge one.

func (*TransactOpts) Opts

func (t *TransactOpts) Opts() *bind.TransactOpts

Opts returns the go-ethereum transactor for bindings.

type WriteContext

type WriteContext struct{ Context }

WriteContext is the request view available to Write handlers. Transactor is the only way HTTP handlers may obtain submit opts.

func (WriteContext) Transactor

func (c WriteContext) Transactor() (*TransactOpts, error)

Transactor returns submit opts with gas fields from the request form.

type WriteRoute

type WriteRoute struct {
	// contains filtered or unexported fields
}

WriteRoute always requires a bearer token: transaction submission and high-impact local operations (wallet secrets, exits, signing).

func Write

func Write(path string, h func(WriteContext)) WriteRoute

Write returns a route that always requires a bearer token.

func (WriteRoute) Path

func (r WriteRoute) Path() string

func (WriteRoute) RegisterTo

func (r WriteRoute) RegisterTo(router *Router)

func (WriteRoute) RequiresToken

func (WriteRoute) RequiresToken(bool) bool

Jump to

Keyboard shortcuts

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