Skip to content

Commit 22c07f7

Browse files
support multiple REST API versions
1 parent 1f13820 commit 22c07f7

25 files changed

Lines changed: 97 additions & 32 deletions
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019-2021, The Decred developers
1+
// Copyright (c) 2019-2022, The Decred developers
22
// Copyright (c) 2017, Jonathan Chappelow
33
// See LICENSE for details.
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018-2021, The Decred developers
1+
// Copyright (c) 2018-2022, The Decred developers
22
// Copyright (c) 2017, Jonathan Chappelow
33
// See LICENSE for details.
44

blockdata/blockdata.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020-2021, The Decred developers
1+
// Copyright (c) 2020-2022, The Decred developers
22
// Copyright (c) 2017, Jonathan Chappelow
33
// See LICENSE for details.
44

@@ -16,7 +16,7 @@ import (
1616
chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v4"
1717
"github.com/decred/dcrd/wire"
1818

19-
apitypes "github.com/decred/dcrdata/v8/api/types"
19+
apitypes "github.com/decred/dcrdata/v8/api/types/v1"
2020
"github.com/decred/dcrdata/v8/db/dbtypes"
2121
"github.com/decred/dcrdata/v8/stakedb"
2222
"github.com/decred/dcrdata/v8/txhelpers"

cmd/dcrdata/internal/api/apirouter.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ type apiMux struct {
1818
*chi.Mux
1919
}
2020

21+
// Versions returns a list of API versions supported.
22+
func (am *apiMux) Versions() []APIVersion {
23+
return supportedAPIVersions[:]
24+
}
25+
2126
type fileMux struct {
2227
*chi.Mux
2328
}

cmd/dcrdata/internal/api/apiroutes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
"github.com/decred/dcrdata/exchanges/v3"
3737
"github.com/decred/dcrdata/gov/v6/agendas"
3838
"github.com/decred/dcrdata/gov/v6/politeia"
39-
apitypes "github.com/decred/dcrdata/v8/api/types"
39+
apitypes "github.com/decred/dcrdata/v8/api/types/v1"
4040
"github.com/decred/dcrdata/v8/db/cache"
4141
"github.com/decred/dcrdata/v8/db/dbtypes"
4242
"github.com/decred/dcrdata/v8/txhelpers"
@@ -160,7 +160,7 @@ func NewContext(cfg *AppContextConfig) *appContext {
160160
xcBot: cfg.XcBot,
161161
AgendaDB: cfg.AgendasDBInstance,
162162
ProposalsDB: cfg.ProposalsDB,
163-
Status: apitypes.NewStatus(uint32(nodeHeight), conns, APIVersion, cfg.AppVer, cfg.Params.Name),
163+
Status: apitypes.NewStatus(uint32(nodeHeight), conns, currentAPIVersion, cfg.AppVer, cfg.Params.Name),
164164
maxCSVAddrs: cfg.MaxAddrs,
165165
charts: cfg.Charts,
166166
}

cmd/dcrdata/internal/api/insight/apimiddleware.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"strings"
1616

1717
m "github.com/decred/dcrdata/cmd/dcrdata/internal/middleware"
18-
apitypes "github.com/decred/dcrdata/v8/api/types"
18+
apitypes "github.com/decred/dcrdata/v8/api/types/v1"
1919
"github.com/go-chi/chi/v5"
2020
)
2121

cmd/dcrdata/internal/api/insight/apirouter.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ type ApiMux struct {
1919
*chi.Mux
2020
}
2121

22-
// APIVersion is an integer value, incremented for breaking changes
23-
const APIVersion = 0
22+
// Versions returns a list of API versions supported.
23+
func (am *ApiMux) Versions() []APIVersion {
24+
return supportedAPIVersions[:]
25+
}
2426

2527
// NewInsightAPIRouter returns a new HTTP path router, ApiMux, for the Insight
2628
// API, app.

0 commit comments

Comments
 (0)