Documentation
¶
Index ¶
- Constants
- func AddAnuraHeaders(req *retryablehttp.Request, privateKey *ecdsa.PrivateKey, address string) error
- func AddHeaders(req *retryablehttp.Request, privateKey *ecdsa.PrivateKey, address string) error
- func CheckAnuraSignature(req *http.Request, approvedAddresses []string) (string, error)
- func CheckSignature(req *http.Request) (string, error)
- func ConnectWebSocket(url string, ctx context.Context) chan []byte
- func CorsMiddleware(next http.Handler) http.Handler
- func GenericJSONPostClient(url string, json string) (*http.Response, error)
- func GetHandler[T any](handler httpGetWrapper[T]) func(res http.ResponseWriter, req *http.Request)
- func GetRequest[ResultType any](options ClientOptions, path string, queryParams map[string]string) (ResultType, error)
- func GetRequestBuffer(options ClientOptions, path string, queryParams map[string]string) (*bytes.Buffer, error)
- func GetVersionFromHeaders(req *http.Request) (string, error)
- func IsAnura(req *http.Request, approvedAddresses []string) bool
- func PostHandler[RequestType any, ResultType any](handler httpPostWrapper[RequestType, ResultType]) func(res http.ResponseWriter, req *http.Request)
- func PostRequest[RequestType any, ResultType any](options ClientOptions, path string, data RequestType) (ResultType, error)
- func PostRequestBuffer[ResultType any](options ClientOptions, path string, data *bytes.Buffer) (ResultType, error)
- func PostRequestBufferWithHeaders[ResultType any](options ClientOptions, path string, headers map[string]string, ...) (ResultType, error)
- func ReadBody[T any](req *http.Request) (T, error)
- func StartWebSocketServer(r *mux.Router, path string, messageChan chan []byte, ctx context.Context, ...)
- func URL(options ClientOptions, path string) string
- func WebsocketURL(options ClientOptions, path string) string
- type AccessControlOptions
- type AuthUser
- type ClientOptions
- type ConnectionWrapper
- type HTTPError
- type RateLimiterOptions
- type ServerOptions
- type StorageOptions
- type ValidationToken
- type WSConnectionParams
Constants ¶
const API_SUB_PATH = "/api/v1"
the sub path any API's are served over
const CONTEXT_ADDRESS = "address"
the context name we keep the address
const WEBSOCKET_SUB_PATH = "/ws"
the sub path the websocket server is mounted on
const X_ANURA_SERVER_HEADER = "X-Anura-Server"
the address of the anura server
const X_ANURA_SIGNATURE_HEADER = "X-Anura-Key"
the signature of the anura server
const X_LILYPAD_SIGNATURE_HEADER = "X-Lilypad-Signature"
this is the signature of the message
const X_LILYPAD_USER_HEADER = "X-Lilypad-User"
write some string constants for x-lilypad headers this is the address of the user
const X_LILYPAD_VERSION_HEADER = "X-Lilypad-Version"
the version run by the client or service
Variables ¶
This section is empty.
Functions ¶
func AddAnuraHeaders ¶
func AddAnuraHeaders( req *retryablehttp.Request, privateKey *ecdsa.PrivateKey, address string, ) error
func AddHeaders ¶
func AddHeaders( req *retryablehttp.Request, privateKey *ecdsa.PrivateKey, address string, ) error
func CheckAnuraSignature ¶
func CheckSignature ¶
Use the client headers to ensure that a message was signed by the holder of a private key for a specific address. The "X-Lilypad-User" header contains the address. The "X-Lilypad-Signature" header contains the signature. We use the signature to verify that the message was signed by the private key.
func ConnectWebSocket ¶
ConnectWebSocket establishes a new WebSocket connection
func GenericJSONPostClient ¶
func GetHandler ¶
func GetHandler[T any](handler httpGetWrapper[T]) func(res http.ResponseWriter, req *http.Request)
wrap a http handler with some error handling so if it returns an error we handle it
func GetRequest ¶
func GetRequestBuffer ¶
func PostHandler ¶
func PostRequest ¶
func PostRequest[RequestType any, ResultType any]( options ClientOptions, path string, data RequestType, ) (ResultType, error)
func PostRequestBuffer ¶
func PostRequestBufferWithHeaders ¶ added in v2.19.0
func StartWebSocketServer ¶
func StartWebSocketServer( r *mux.Router, path string, messageChan chan []byte, ctx context.Context, connectCB func(params WSConnectionParams), disconnectCB func(params WSConnectionParams), )
StartWebSocketServer starts a WebSocket server
func URL ¶
func URL(options ClientOptions, path string) string
func WebsocketURL ¶
func WebsocketURL(options ClientOptions, path string) string
Types ¶
type AccessControlOptions ¶
type ClientOptions ¶
type ConnectionWrapper ¶
type ConnectionWrapper struct {
// contains filtered or unexported fields
}
type RateLimiterOptions ¶
type ServerOptions ¶
type ServerOptions struct {
URL string
Host string
Port int
AccessControl AccessControlOptions
RateLimiter RateLimiterOptions
Storage StorageOptions
}
type StorageOptions ¶ added in v2.19.0
type ValidationToken ¶
type ValidationToken struct {
JWT string
}