Add support for simple function calls in url header of the http processor#2179
Merged
Add support for simple function calls in url header of the http processor#2179
url header of the http processor#2179Conversation
functions can now be used at `url` header of the http processor. This allows the following code snippet to work: ```ftd -- import: fastn/processors ;; this could come from request-data processor for example ;; or some other reference, like: ;; -- string v: $some-other-reference -- string v: foo -- string x: $processor$: processors.http url: $some-func(v = $v) -- string some-func(v): string v: "/api/" + v + "/" ``` ** Known issues - The function can't be a js function (a function definition with js: header) since we don't execute js on the server. - Typecheck between function params and args is not correct. While constructing the function call, we use the param's type for the arg's type. The right thing here is to resolve the reference and use the resolved type so that type check happens correctly. There's a TODO comment for this. - The function body supports simple expressions only and has been only tested with the + operator expression. To learn more about the full supported constructs, see the evalexpr crate.
If one of the subexpr for the + OP is different than the other, differ to string concatenation by converting the number to string.
amitu
approved these changes
Aug 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
functions can now be used at
urlheader of the http processor. Thisallows the following code snippet to work:
Known issues
The function can't be a js function (a function definition with js:
header) since we don't execute js on the server.
Typecheck between function params and args is not correct. While
constructing the function call, we use the param's type for the arg's
type. The right thing here is to resolve the reference and use the
resolved type so that type check happens correctly. There's a TODO
comment for this.
The function body supports simple expressions only and has been only
tested with the + operator expression. To learn more about the full
supported constructs, see the evalexpr crate.