-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (34 loc) · 995 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package api
import (
"context"
"time"
"github.com/go-chi/chi"
"github.com/rarimo/dex-pairs-oracle/internal/config"
"github.com/rarimo/dex-pairs-oracle/internal/services/api/handlers"
"gitlab.com/distributed_lab/ape"
)
func Run(ctx context.Context, cfg config.Config) {
r := chi.NewRouter()
const slowRequestDurationThreshold = time.Second
ape.DefaultMiddlewares(r, cfg.Log(), slowRequestDurationThreshold)
r.Use(
ape.RecoverMiddleware(cfg.Log()),
ape.LoganMiddleware(cfg.Log()),
ape.CtxMiddleware(
handlers.CtxLog(cfg.Log()),
handlers.CtxConfig(cfg),
),
)
r.Route("/dexoracle", func(r chi.Router) {
r.Route("/chains", func(r chi.Router) {
r.Get("/", handlers.ListSupportedChain)
r.Route("/evm", func(r chi.Router) {
r.Route("/{chain_name}", func(r chi.Router) {
r.Get("/tokens", handlers.ListSupportedEVMTokens)
r.Get("/{account_address}/balances", handlers.ListEVMBalances)
})
})
})
})
ape.Serve(ctx, r, cfg, ape.ServeOpts{})
}