Documentation ¶
Index ¶
- Variables
- func ConnectionID(r *http.Request) string
- func ConnectionIsGone(err error) bool
- func DefaultRouteKeySelector(body []byte) (string, error)
- func DeleteConnection(ctx context.Context, connectionID string) error
- func EventType(r *http.Request) string
- func ExitsConnection(ctx context.Context, connectionID string) (bool, error)
- func GetConnection(ctx context.Context, connectionID string) (*apigatewaymanagementapi.GetConnectionOutput, error)
- func NewManagementAPIClient(ctx context.Context) (*apigatewaymanagementapi.Client, error)
- func NewRequest(event json.RawMessage) (*http.Request, error)
- func NewRequestWithContext(ctx context.Context, event json.RawMessage) (*http.Request, error)
- func PostToConnection(ctx context.Context, connectionID string, data []byte) error
- func ProxyRequestContext(ctx context.Context) events.APIGatewayWebsocketProxyRequestContext
- func RequestID(r *http.Request) string
- func RouteKey(r *http.Request) string
- func Run(mux http.Handler) error
- func RunWithOptions(mux http.Handler, options ...Option) error
- type Option
- func WithAWSConfig(config *aws.Config) Option
- func WithContext(ctx context.Context) Option
- func WithLambdaOptions(options ...lambda.Option) Option
- func WithListener(listener net.Listener) Option
- func WithLocalAdress(address string) Option
- func WithLogger(logger *slog.Logger) Option
- func WithRouteKeySelector(selector RouteKeySelector) Option
- func WithVerbose() Option
- type ResponseWriter
- type RouteKeySelector
- type WebsocketHTTPBridgeHandler
- func (h *WebsocketHTTPBridgeHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (h *WebsocketHTTPBridgeHandler) SetCallbackURL(callbackURL string)
- func (h *WebsocketHTTPBridgeHandler) SetLogger(logger *slog.Logger)
- func (h *WebsocketHTTPBridgeHandler) SetRouteKeySelector(selector RouteKeySelector)
- func (h *WebsocketHTTPBridgeHandler) SetVerbose(verbose bool)
Constants ¶
This section is empty.
Variables ¶
var ( HTTPHeaderConnectionID = "Elevate-Connection-Id" HTTPHeaderRequestID = "Elevate-Request-Id" HTTPHeaderEventType = "Elevate-Event-Type" HTTPHeaderRouteKey = "Elevate-Route-Key" )
var DefaultContentType = "text/plain; charset=utf-8"
DefaultContentType is a default content-type when missing in response.
var TextMimeTypes = []string{"image/svg+xml", "application/json", "application/xml"}
TextMimeTypes is a list of identified as text.
Functions ¶
func ConnectionID ¶
ConnectionID returns connection id from *http.Request.
func ConnectionIsGone ¶
ConnectionIsGone returns true if err is GoneException.
func DefaultRouteKeySelector ¶
DefaultRouteKeySelector is a default RouteKeySelector. it returns "action" key from request body.
func DeleteConnection ¶
DeleteConnection deletes connectionID.
func ExitsConnection ¶
ExitsConnection returns true if connectionID exists.
func GetConnection ¶
func GetConnection(ctx context.Context, connectionID string) (*apigatewaymanagementapi.GetConnectionOutput, error)
GetConnection gets connectionID.
func NewManagementAPIClient ¶
func NewManagementAPIClient(ctx context.Context) (*apigatewaymanagementapi.Client, error)
func NewRequest ¶
func NewRequest(event json.RawMessage) (*http.Request, error)
NewRequest creates *net/http.Request from a Request.
func NewRequestWithContext ¶
NewRequestWithContext creates *net/http.Request from a Request with context.
func PostToConnection ¶
PostToConnection posts data to connectionID.
func ProxyRequestContext ¶
func ProxyRequestContext(ctx context.Context) events.APIGatewayWebsocketProxyRequestContext
Types ¶
type Option ¶
type Option func(*runOptions)
func WithAWSConfig ¶
WithAWSConfig sets aws.Config to runOptions. only for AWS Lambda Runtime. default is loaded default config.
func WithContext ¶
WithContext sets context.Context to runOptions.
func WithLambdaOptions ¶
WithLambdaOptions sets lambda.Options to runOptions. only for AWS Lambda Runtime.
func WithListener ¶
WithListener sets net.Listener to runOptions. only for local.
func WithLocalAdress ¶
WithLocalAdress sets local address to runOptions.
func WithLogger ¶
WithLogger sets slog.Logger to runOptions.
func WithRouteKeySelector ¶
func WithRouteKeySelector(selector RouteKeySelector) Option
WithRouteKeySelector sets RouteKeySelector to runOptions. only for local.
type ResponseWriter ¶
ResponeWriter represents a response writer implements http.ResponseWriter.
func NewResponseWriter ¶
func NewResponseWriter() *ResponseWriter
func (*ResponseWriter) Header ¶
func (w *ResponseWriter) Header() http.Header
func (*ResponseWriter) Response ¶
func (w *ResponseWriter) Response() *events.APIGatewayProxyResponse
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(code int)
type RouteKeySelector ¶
RouteKeySelector is a function to select route key from request body. for local.
type WebsocketHTTPBridgeHandler ¶
type WebsocketHTTPBridgeHandler struct { Handler http.Handler websocket.Upgrader // contains filtered or unexported fields }
func NewWebsocketHTTPBridgeHandler ¶
func NewWebsocketHTTPBridgeHandler(handler http.Handler) *WebsocketHTTPBridgeHandler
func (*WebsocketHTTPBridgeHandler) ServeHTTP ¶
func (h *WebsocketHTTPBridgeHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
func (*WebsocketHTTPBridgeHandler) SetCallbackURL ¶
func (h *WebsocketHTTPBridgeHandler) SetCallbackURL(callbackURL string)
func (*WebsocketHTTPBridgeHandler) SetLogger ¶
func (h *WebsocketHTTPBridgeHandler) SetLogger(logger *slog.Logger)
func (*WebsocketHTTPBridgeHandler) SetRouteKeySelector ¶
func (h *WebsocketHTTPBridgeHandler) SetRouteKeySelector(selector RouteKeySelector)
func (*WebsocketHTTPBridgeHandler) SetVerbose ¶
func (h *WebsocketHTTPBridgeHandler) SetVerbose(verbose bool)