Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added parameter date functions in custom-api #574

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

ralphocdol
Copy link
Contributor

From my Issue #502, I wanted to have a way to have a date today in the parameter of the custom-api as some API would need to receive those dates. Mainly the startOfDay and endOfDay to filter some API directly and there was no way to do it, and sometimes the API themselves doesn't support today data for some reason.

Configuration example

- type: custom-api
  url: https:${WEBSERVER_URL}/test-request
  parameters:
    now: { now }
    now-utc: { now UTC }
    start-of-day: { startOfDay }
    end-of-day: { endOfDay }
    start-of-day-utc: { startOfDay UTC }
    end-of-day-utc: { endOfDay UTC }
    normal-string: i am a string
  cache: 1s
  template: |
    <div><pre>now:                {{ .JSON.String "now" }}</pre></div>
    <div><pre>now-utc:            {{ .JSON.String "now-utc" }}</pre></div>
    <div><pre>start-of-day:       {{ .JSON.String "start-of-day" }}</pre></div>
    <div><pre>end-of-day:         {{ .JSON.String "end-of-day" }}</pre></div>
    <div><pre>start-of-day-utc:   {{ .JSON.String "start-of-day-utc" }}</pre></div>
    <div><pre>end-of-day-utc:     {{ .JSON.String "end-of-day-utc" }}</pre></div>
    <div><pre>normal-string:      {{ .JSON.String "normal-string" }}</pre></div>

Output

Screenshot_20250410_002116

@ralphocdol ralphocdol changed the title Added date parameter functions in custom-api Added parameter date functions in custom-api Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant