Skip to content

preprocess

import "github.com/HexmosTech/lama2/preprocess"

Package preprocess provides facilities to expand environment variables in `.l2` API files and return the contents

Index

func Expand

func Expand(s string, vm *goja.Runtime, mapping map[string]string) string

Expand replaces ${var} or $var in the string based on the mapping function. For example, os.ExpandEnv(s) is equivalent to os.Expand(s, os.Getenv).

func ExpandEnv

func ExpandEnv(s string, vm *goja.Runtime) string

ExpandEnv replaces ${var} or $var in the string according to the values of the current environment variables. References to undefined variables are replaced by the empty string.

func ExpandHeaders

func ExpandHeaders(block *gabs.Container, vm *goja.Runtime)

func ExpandJSON

func ExpandJSON(block *gabs.Container, vm *goja.Runtime)

func ExpandURL

func ExpandURL(block *gabs.Container, vm *goja.Runtime)

func GetL2EnvVariables

func GetL2EnvVariables(dir string) (map[string]map[string]interface{}, error)

func GetLamaFileAsString

func GetLamaFileAsString(path string) string

func LamaFile

func LamaFile(inputFile string) (string, string)

LamaFile takes in a path to an API file. It moves into the API file directory, reads the API contents, loads the `l2.env` file if available, and finally substitutes environment vars in the API contents Once done, it reverts back to the original directory, and returns the processed l2 file.

func LoadEnvFile

func LoadEnvFile(l2path string)

func LoadEnvironments

func LoadEnvironments(dir string)

func ProcessVarsInBlock

func ProcessVarsInBlock(block *gabs.Container, vm *goja.Runtime)

func SearchL2ConfigEnv

func SearchL2ConfigEnv(dir string) (string, error)

Generated by gomarkdoc