Documentation ¶
Index ¶
- Constants
- Variables
- func ErrBadrequest(w http.ResponseWriter, r *http.Request, errorText string)
- func ErrInternalServerError(w http.ResponseWriter, r *http.Request, errorText string)
- func ErrInvalidRequest(w http.ResponseWriter, r *http.Request)
- func ErrUnsupportedAction(w http.ResponseWriter, r *http.Request)
- func WebsocketChl(hub *Hub, w http.ResponseWriter, r *http.Request)
- type Client
- type ErrorResponse
- type HttpController
- type Hub
Constants ¶
View Source
const ( // Time allowed to write a message to the peer. WriteWait = 10 * time.Second // Time allowed to read the next pong message from the peer. PongWait = 60 * time.Second // Send pings to peer with this period. Must be less than pongWait. PingPeriod = (PongWait * 9) / 10 // Maximum message size allowed from peer. MaxMessageSize = 512 )
Variables ¶
View Source
var InvalidRequestError = ErrorResponse{
Error: "The request was invalid and not recognized",
}
View Source
var UnsupportedActionError = ErrorResponse{
Error: "The requested action is not supported in this API",
}
View Source
var Upgrader = websocket.Upgrader{}
Functions ¶
func ErrBadrequest ¶
func ErrBadrequest(w http.ResponseWriter, r *http.Request, errorText string)
func ErrInternalServerError ¶
func ErrInternalServerError(w http.ResponseWriter, r *http.Request, errorText string)
func ErrInvalidRequest ¶
func ErrInvalidRequest(w http.ResponseWriter, r *http.Request)
func ErrUnsupportedAction ¶
func ErrUnsupportedAction(w http.ResponseWriter, r *http.Request)
func WebsocketChl ¶
func WebsocketChl(hub *Hub, w http.ResponseWriter, r *http.Request)
Handles a ws connection request from user
Types ¶
type Client ¶
type Client struct { Hub *Hub // The websocket connection. Conn *websocket.Conn // Buffered channel of outbound messages. Send chan []byte // IP Address IPAddress string ID uuid.UUID Accounts []string // Subscribed accounts Currency string // contains filtered or unexported fields }
Client is a middleman between the websocket connection and the hub.
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
type HttpController ¶
type HttpController struct { RPCClient *net.RPCClient BananoMode bool FcmTokenRepo *repository.FcmTokenRepo FcmClient *fcm.Client }
func (*HttpController) HandleAction ¶
func (hc *HttpController) HandleAction(w http.ResponseWriter, r *http.Request)
HandleHTTPRequest handles all requests to the http server It's generally designed to mimic the nano node's RPC API Though we do additional processing in the middle for some actions
func (*HttpController) HandleHTTPCallback ¶
func (hc *HttpController) HandleHTTPCallback(w http.ResponseWriter, r *http.Request)
HTTP Callback is only for push notifications
type Hub ¶
type Hub struct { // Registered clients. Clients map[*Client]bool // Outbound messages to the client Broadcast chan []byte // Register requests from the clients. Register chan *Client // Unregister requests from clients. Unregister chan *Client BananoMode bool PricePrefix string RPCClient *net.RPCClient FcmTokenRepo *repository.FcmTokenRepo }
Hub maintains the set of active clients and broadcasts messages to the clients.
func NewHub ¶
func NewHub(bananomode bool, rpcClient *net.RPCClient, fcmTokenRepo *repository.FcmTokenRepo) *Hub
func (*Hub) BroadcastToClient ¶
Click to show internal directories.
Click to hide internal directories.