Documentation ¶
Index ¶
- Constants
- func AddHeaders(req *retryablehttp.Request, privateKey *ecdsa.PrivateKey, address string) error
- func ConnectWebSocket(url string, messageChan chan []byte, ctx context.Context) *websocket.Conn
- func CorsMiddleware(next http.Handler) http.Handler
- func GetAddressFromHeaders(req *http.Request) (string, 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 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 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 AuthUser
- type ClientOptions
- type ConnectionWrapper
- type HTTPError
- type ServerOptions
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_LILYPAD_SIGNATURE_HEADER = "X-Lilypad-Signature"
this is the signature of the message
const X_LILYPAD_USER_HEADER = "X-Lilypad-User"
TODO: Revert to previous version after solver deployment @Luke write some string constants for x-lilypad headers this is the address of the user
Variables ¶
This section is empty.
Functions ¶
func AddHeaders ¶
func AddHeaders( req *retryablehttp.Request, privateKey *ecdsa.PrivateKey, address string, ) error
func ConnectWebSocket ¶
ConnectWebSocket establishes a new WebSocket connection
func GetAddressFromHeaders ¶
this will use the client headers to ensure that a message was signed by the holder of a private key for a specific address there is a "X-CoopHive-User" header that will contain the address there is a "X-CoopHive-Signature" header that will contain the signature we use the signature to verify that the message was signed by the private key
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 StartWebSocketServer ¶
func StartWebSocketServer( r *mux.Router, path string, messageChan chan []byte, ctx context.Context, )
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 ClientOptions ¶
type ConnectionWrapper ¶
type ConnectionWrapper struct {
// contains filtered or unexported fields
}