resolved meta conundrum
This commit is contained in:
parent
783dd623e3
commit
982107dbc2
@ -73,11 +73,6 @@ type Rpki struct {
|
||||
Invalid []string `json:"invalid"`
|
||||
}
|
||||
|
||||
// A BackendResponse contains meta information.
|
||||
type BackendResponse struct {
|
||||
Meta Meta `json:"api"`
|
||||
}
|
||||
|
||||
// Meta contains response meta information
|
||||
// like cacheing time and cache ttl or the API version
|
||||
type Meta struct {
|
||||
@ -106,8 +101,8 @@ type Status struct {
|
||||
|
||||
// StatusResponse ??
|
||||
type StatusResponse struct {
|
||||
BackendResponse
|
||||
Status Status `json:"status"`
|
||||
Meta *Meta `json:"api"`
|
||||
}
|
||||
|
||||
// A RouteServer is a datasource with attributes.
|
||||
|
@ -89,8 +89,8 @@ func (n *Neighbor) MatchName(name string) bool {
|
||||
// A NeighborsResponse is a list of neighbors with
|
||||
// caching information.
|
||||
type NeighborsResponse struct {
|
||||
BackendResponse
|
||||
Neighbors Neighbors `json:"neighbors"`
|
||||
Meta *Meta `json:"api"`
|
||||
}
|
||||
|
||||
// CacheTTL returns the duration of validity
|
||||
@ -130,6 +130,6 @@ func (neighbors NeighborsStatus) Swap(i, j int) {
|
||||
// NeighborsStatusResponse contains the status of all neighbors
|
||||
// on a RS.
|
||||
type NeighborsStatusResponse struct {
|
||||
BackendResponse
|
||||
Neighbors NeighborsStatus `json:"neighbors"`
|
||||
Meta *Meta `json:"api"`
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ func (routes Routes) Swap(i, j int) {
|
||||
|
||||
// RoutesResponse contains all routes from a source
|
||||
type RoutesResponse struct {
|
||||
BackendResponse
|
||||
Meta *Meta `json:api`
|
||||
Imported Routes `json:"imported"`
|
||||
Filtered Routes `json:"filtered"`
|
||||
NotExported Routes `json:"not_exported"`
|
||||
@ -78,7 +78,7 @@ type RoutesResponse struct {
|
||||
// CacheTTL returns the cache ttl of the reponse
|
||||
func (res *RoutesResponse) CacheTTL() time.Duration {
|
||||
now := time.Now().UTC()
|
||||
return res.BackendResponse.Meta.TTL.Sub(now)
|
||||
return res.Meta.TTL.Sub(now)
|
||||
}
|
||||
|
||||
// Timed responses include the duration of the request
|
||||
@ -161,11 +161,11 @@ func (r LookupRoutes) Swap(i, j int) {
|
||||
// a set of lookup routes, as the result of a query of
|
||||
// a specific route server.
|
||||
type RoutesLookupResponse struct {
|
||||
Response
|
||||
Paginated
|
||||
Timed
|
||||
Searchable
|
||||
Routes LookupRoutes `json:"routes"`
|
||||
Meta *Meta `json:"api"`
|
||||
}
|
||||
|
||||
// GlobalRoutesLookupResponse is the result of a routes
|
||||
|
@ -10,13 +10,11 @@ func TestStatusResponseSerialization(t *testing.T) {
|
||||
|
||||
// Make status
|
||||
response := StatusResponse{
|
||||
Response: Response{
|
||||
Meta: Meta{
|
||||
Version: "2.0.0",
|
||||
CacheStatus: CacheStatus{},
|
||||
ResultFromCache: false,
|
||||
TTL: time.Now(),
|
||||
},
|
||||
Meta: &Meta{
|
||||
Version: "2.0.0",
|
||||
CacheStatus: CacheStatus{},
|
||||
ResultFromCache: false,
|
||||
TTL: time.Now(),
|
||||
},
|
||||
Status: Status{
|
||||
Message: "Server is up and running",
|
||||
|
Loading…
x
Reference in New Issue
Block a user