Files
aperture/pricer/defaultPricer.go
Olaoluwa Osuntokun 40df8f8339 proxy+pricer: pass in the entire HTTP requests for GetPrice
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.
2023-06-13 20:43:14 -05:00

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
}