templates

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplacePlaceHoldersVariables

func ReplacePlaceHoldersVariables(template string, dico map[string]string, rawEvent any, headers http.Header, changedFiles map[string]interface{}) string

ReplacePlaceHoldersVariables is a function that replaces placeholders in a given string template with their corresponding values. The placeholders are expected to be in the format `{{key}}`, where `key` is the identifier for a value.

The function first checks if the key in the placeholder has a prefix of "body", "headers", or "files". If it does and both `rawEvent` and `headers` are not nil, it attempts to retrieve the value for the key using the `customparams.CelValue` function and returns the corresponding string representation. If the key does not have any of the mentioned prefixes, the function checks if the key exists in the `dico` map. If it does, the function replaces the placeholder with the corresponding value from the `dico` map.

Parameters:

  • template (string): The input string that may contain placeholders in the format `{{key}}`.
  • dico (map[string]string): A dictionary mapping keys to their corresponding string values. If a placeholder's key is found in this dictionary, it will be replaced with the corresponding value.
  • rawEvent (any): The raw event data that may be used to retrieve values for placeholders with keys that have a prefix of "body", "headers", or "files".
  • headers (http.Header): The HTTP headers that may be used to retrieve values for placeholders with keys that have a prefix of "headers".
  • changedFiles (map[string]interface{}): A map of changed files that may be used to retrieve values for placeholders with keys that have a prefix of "files".

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL