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.
This commit is contained in:
Olaoluwa Osuntokun
2023-06-06 18:50:57 -07:00
parent 3a5dd96a95
commit 40df8f8339
4 changed files with 25 additions and 11 deletions

View File

@@ -155,9 +155,7 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// resources.
acceptAuth := p.authenticator.Accept(&r.Header, resourceName)
if !acceptAuth {
price, err := target.pricer.GetPrice(
r.Context(), r.URL.Path,
)
price, err := target.pricer.GetPrice(r.Context(), r)
if err != nil {
prefixLog.Errorf("error getting "+
"resource price: %v", err)
@@ -197,7 +195,7 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
if !ok {
price, err := target.pricer.GetPrice(
r.Context(), r.URL.Path,
r.Context(), r,
)
if err != nil {
prefixLog.Errorf("error getting "+