docs(ax): improve public route and log examples
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
2a49caca03
commit
05b0bb5ea4
2 changed files with 11 additions and 7 deletions
|
|
@ -11,13 +11,17 @@ import (
|
|||
"dappco.re/go/proxy"
|
||||
)
|
||||
|
||||
type Router interface {
|
||||
// RouteRegistrar accepts HTTP handler registrations.
|
||||
//
|
||||
// mux := http.NewServeMux()
|
||||
// api.RegisterRoutes(mux, p)
|
||||
type RouteRegistrar interface {
|
||||
HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
|
||||
}
|
||||
|
||||
// mux := http.NewServeMux()
|
||||
// api.RegisterRoutes(mux, p) // GET /1/summary, /1/workers, /1/miners
|
||||
func RegisterRoutes(router Router, p *proxy.Proxy) {
|
||||
func RegisterRoutes(router RouteRegistrar, p *proxy.Proxy) {
|
||||
if router == nil || p == nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -26,7 +30,7 @@ func RegisterRoutes(router Router, p *proxy.Proxy) {
|
|||
registerJSONGetRoute(router, p, "/1/miners", func() any { return p.MinersDocument() })
|
||||
}
|
||||
|
||||
func registerJSONGetRoute(router Router, authoriser *proxy.Proxy, pattern string, renderDocument func() any) {
|
||||
func registerJSONGetRoute(router RouteRegistrar, authoriser *proxy.Proxy, pattern string, renderDocument func() any) {
|
||||
router.HandleFunc(pattern, func(w http.ResponseWriter, request *http.Request) {
|
||||
if status, ok := allowMonitoringRequest(authoriser, request); !ok {
|
||||
switch status {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ func (l *AccessLog) Close() {
|
|||
}
|
||||
}
|
||||
|
||||
// OnLogin writes a CONNECT line.
|
||||
// OnLogin writes `2026-04-04T12:00:00Z CONNECT 10.0.0.1 WALLET XMRig/6.21.0`.
|
||||
func (l *AccessLog) OnLogin(e proxy.Event) {
|
||||
if l == nil || e.Miner == nil {
|
||||
return
|
||||
|
|
@ -41,7 +41,7 @@ func (l *AccessLog) OnLogin(e proxy.Event) {
|
|||
l.writeConnectLine(e.Miner.IP(), e.Miner.User(), e.Miner.Agent())
|
||||
}
|
||||
|
||||
// OnClose writes a CLOSE line with byte counts.
|
||||
// OnClose writes `2026-04-04T12:00:00Z CLOSE 10.0.0.1 WALLET rx=512 tx=4096`.
|
||||
func (l *AccessLog) OnClose(e proxy.Event) {
|
||||
if l == nil || e.Miner == nil {
|
||||
return
|
||||
|
|
@ -73,7 +73,7 @@ func (l *ShareLog) Close() {
|
|||
}
|
||||
}
|
||||
|
||||
// OnAccept writes an ACCEPT line.
|
||||
// OnAccept writes `2026-04-04T12:00:00Z ACCEPT WALLET diff=100000 latency=82ms`.
|
||||
func (l *ShareLog) OnAccept(e proxy.Event) {
|
||||
if l == nil || e.Miner == nil {
|
||||
return
|
||||
|
|
@ -81,7 +81,7 @@ func (l *ShareLog) OnAccept(e proxy.Event) {
|
|||
l.writeAcceptLine(e.Miner.User(), e.Diff, uint64(e.Latency))
|
||||
}
|
||||
|
||||
// OnReject writes a REJECT line.
|
||||
// OnReject writes `2026-04-04T12:00:00Z REJECT WALLET reason="Invalid nonce"`.
|
||||
func (l *ShareLog) OnReject(e proxy.Event) {
|
||||
if l == nil || e.Miner == nil {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue