mirror of
https://github.com/cf-sonr/radar.git
synced 2026-01-12 02:59:13 +00:00
36 lines
484 B
Go
36 lines
484 B
Go
|
|
//go:build js && wasm
|
||
|
|
// +build js,wasm
|
||
|
|
|
||
|
|
package api
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"github.com/syumai/workers/cloudflare/fetch"
|
||
|
|
)
|
||
|
|
|
||
|
|
type Response interface {
|
||
|
|
UnmarshalJSON(data []byte) error
|
||
|
|
}
|
||
|
|
|
||
|
|
type Client interface {
|
||
|
|
MarketAPI
|
||
|
|
}
|
||
|
|
|
||
|
|
type client struct {
|
||
|
|
fc *fetch.Client
|
||
|
|
ctx context.Context
|
||
|
|
MarketAPI
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewClient(ctx context.Context) *client {
|
||
|
|
fc := fetch.NewClient()
|
||
|
|
c := &client{
|
||
|
|
fc: fc,
|
||
|
|
ctx: ctx,
|
||
|
|
}
|
||
|
|
marketAPI := NewMarketAPI(c, ctx)
|
||
|
|
c.MarketAPI = marketAPI
|
||
|
|
return c
|
||
|
|
}
|