VCL alter is inflexible

Created on 30 April 2024, 5 months ago

Problem/Motivation

With the VCL alter hook (hook_vcl_handler_data_alter()) it is possible to alter the VCL snippets sent to Fastly.

However it is only possible to have one snippet of each type because the handler uploads the snippets under the name drupalmodule_$type.

It would be good to be able to also upload extra VCL snippets using the alter hook.

Proposed resolution

The attached patch allows the VCL handler to also specify the name to give an uploaded snippet instead just generating it based on the type (drupalmodule_$type).

When adding several snippets it should also be possible to add an priority in the alter hood instead of always using priority 50. The same goes for the "dynamic" property (although I haven't had a use case for that yet myself).

  function hook_vcl_handler_data_alter(array &$data): void {
    $data['vcl'][] = [
      'vcl_dir' => 'my/custom/vcl-snipptes',
      'type' => 'recv',
      'name' => 'my_custom_recv',
      'priority' => 30,
    ];

Remaining tasks

Needs review.

User interface changes

None.

API changes

Added more flexibility to the alter hook, but kept it backwards compatible.

Data model changes

Added more flexibility to the alter hook, but kept it backwards compatible.

Feature request
Status

Needs review

Version

4.0

Component

Code

Created by

🇩🇰Denmark arnested

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024