Question: Accessing Method Value and Endpoint in Connector Class #436
-
I am working on an integration using the Saloon package and need to add an In my request class, I can easily access these values: public function getSignature(): string
{
$combinedString = implode("", [
config('services.api.client_id'),
$this->method->value,
$this->resolveEndpoint(),
'',
time()
]);
return hash_hmac('sha256', $combinedString, config('services.api.client_secret'));
}
protected function defaultHeaders(): array
{
return [
'x-signature' => $this->getSignature(),
];
} However, The getSignature is common for every request and is duplicated. I want to move the signature creation logic to the connector class. Is there a way to access the method value and resolveEndpoint inside the connector class in the Saloon package? What is the best practice for this scenario? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Never mind, i found the solution in the documentation. Just in case if anyone needs https://docs.saloon.dev/digging-deeper/middleware#the-boot-method |
Beta Was this translation helpful? Give feedback.
Never mind, i found the solution in the documentation. Just in case if anyone needs
https://docs.saloon.dev/digging-deeper/middleware#the-boot-method