glance icon indicating copy to clipboard operation
glance copied to clipboard

Added parameter date functions in custom-api

Open ralphocdol opened this issue 8 months ago • 0 comments

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 avatar Apr 09 '25 16:04 ralphocdol