mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
424c8f6b46
* begin the middleware approach * attempt middleware * middleware works in tandem with web ui * handle delete as well * delete request * DELETE working * tool to perform imports * functioning * commentary * build * gaz * smol test * enable keymanager api use protonames * edit * one rule * rem gw * Fix custom compiler (cherry picked from commit 3b1f65919e04ddf7e07c8f60cba1be883a736476) * gen proto * imports * Update validator/node/node.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * remaining comments * update item * rpc * add * run gateway * simplify * rem flag * deep source Co-authored-by: prestonvanloon <preston@prysmaticlabs.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
82 lines
1.7 KiB
Go
82 lines
1.7 KiB
Go
package gateway
|
|
|
|
import (
|
|
"github.com/gorilla/mux"
|
|
"github.com/prysmaticlabs/prysm/api/gateway/apimiddleware"
|
|
)
|
|
|
|
type Option func(g *Gateway) error
|
|
|
|
func (g *Gateway) SetRouter(r *mux.Router) *Gateway {
|
|
g.cfg.router = r
|
|
return g
|
|
}
|
|
|
|
func WithPbHandlers(handlers []*PbMux) Option {
|
|
return func(g *Gateway) error {
|
|
g.cfg.pbHandlers = handlers
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func WithMuxHandler(m MuxHandler) Option {
|
|
return func(g *Gateway) error {
|
|
g.cfg.muxHandler = m
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func WithGatewayAddr(addr string) Option {
|
|
return func(g *Gateway) error {
|
|
g.cfg.gatewayAddr = addr
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func WithRemoteAddr(addr string) Option {
|
|
return func(g *Gateway) error {
|
|
g.cfg.remoteAddr = addr
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithRouter allows adding a custom mux router to the gateway.
|
|
func WithRouter(r *mux.Router) Option {
|
|
return func(g *Gateway) error {
|
|
g.cfg.router = r
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithAllowedOrigins allows adding a set of allowed origins to the gateway.
|
|
func WithAllowedOrigins(origins []string) Option {
|
|
return func(g *Gateway) error {
|
|
g.cfg.allowedOrigins = origins
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithRemoteCert allows adding a custom certificate to the gateway,
|
|
func WithRemoteCert(cert string) Option {
|
|
return func(g *Gateway) error {
|
|
g.cfg.remoteCert = cert
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithMaxCallRecvMsgSize allows specifying the maximum allowed gRPC message size.
|
|
func WithMaxCallRecvMsgSize(size uint64) Option {
|
|
return func(g *Gateway) error {
|
|
g.cfg.maxCallRecvMsgSize = size
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithApiMiddleware allows adding an API middleware proxy to the gateway.
|
|
func WithApiMiddleware(endpointFactory apimiddleware.EndpointFactory) Option {
|
|
return func(g *Gateway) error {
|
|
g.cfg.apiMiddlewareEndpointFactory = endpointFactory
|
|
return nil
|
|
}
|
|
}
|