mirror of
https://github.com/lightninglabs/aperture.git
synced 2026-01-16 07:44:24 +01:00
In this commit, we modify the `GetPrice` method and interface to accept the full request instead of _just_ the path. For backwards compat, we leave the path in place, but also include the full serialized HTTP request.
33 lines
783 B
Go
33 lines
783 B
Go
package pricer
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
)
|
|
|
|
// DefaultPricer provides the same price for any service path. It implements
|
|
// the Pricer interface.
|
|
type DefaultPricer struct {
|
|
Price int64
|
|
}
|
|
|
|
// NewDefaultPricer initialises a new DefaultPricer provider where each resource
|
|
// for the service will have the same price.
|
|
func NewDefaultPricer(price int64) *DefaultPricer {
|
|
return &DefaultPricer{Price: price}
|
|
}
|
|
|
|
// GetPrice returns the price charged for all resources of a service.
|
|
// It is part of the Pricer interface.
|
|
func (d *DefaultPricer) GetPrice(_ context.Context,
|
|
_ *http.Request) (int64, error) {
|
|
|
|
return d.Price, nil
|
|
}
|
|
|
|
// Close is part of the Pricer interface. For the DefaultPricer, the method does
|
|
// nothing.
|
|
func (d *DefaultPricer) Close() error {
|
|
return nil
|
|
}
|