Custom defined functions
jeroenrinzema opened this issue · 0 comments
jeroenrinzema commented
Currently, it is possible to define custom-defined functions and pass them as an argument when initializing Maestro. These functions could be used inside property templates to manipulate data.
Functions could call services to validate values or to generate a new value. The output is returned and could be referenced as a resource.
// define a function called authenticate
function "authenticate" {
input {
token = "string"
}
resource "auth" {
request "maestro.Authenticate" "Authenticate" {
token = "{{ input:token }}"
}
}
output {
valid = "{{ auth:valid }}"
name = "{{ auth:claim.name }}"
}
}
flow "greeter" {
input "maestro.greeter.Request" {}
// resources are functions or properties which are referenced
resources {
auth = "authenticate(input.header:Authorization)",
}
resource "user" {
request "maestro.greeter.Say" "Hello" {
name = "{{ auth:name }}"
}
}
output "maestro.greeter.Response" {
msg = "{{ user:msg }}"
}
}