gatus icon indicating copy to clipboard operation
gatus copied to clipboard

use response body from another endpoint

Open emrahcetiner opened this issue 2 years ago • 3 comments

Describe the feature request

I read all docs completely but I couldn't see any information about this. Is there any way for this? I want to add a sesion-token to endpoints.header from another request's response.

Why do you personally want this feature to be implemented?

No response

How long have you been using this project?

No response

Additional information

No response

emrahcetiner avatar Mar 24 '22 20:03 emrahcetiner

It may be possible like this:

endpoints:
  - name: website                 
    url: "https://twin.sh/health"
    interval: 5m                 
    conditions:
      - "[STATUS] == 200"        
      - "[BODY].status == UP"     
      - "[RESPONSE_TIME] < 300"   
    extract:                                     # <--
      - WEBSITE_TOKEN: "[BODY].data.token"       # <--
  - name: example
    url: "https://example.org/"
    headers:
      token: "[${WEBSITE_TOKEN}]"                # <--
    interval: 60s
    conditions:
      - "[STATUS] == 200"

emrahcetiner avatar Mar 24 '22 21:03 emrahcetiner

@TwiN what do you think about this feature and solution? Should extracted variables be stored in storage or not? I want to contribute, but first, is the design right for the project?

emrahcetiner avatar Mar 28 '22 18:03 emrahcetiner

I tried looking for the relevant issue to no avail, but in the past, I had started considering the implementation of "suites".

Basically, a suite would contain multiple endpoints that would be run in order. If one of them fails, then the suite would be considered as failed.

To start, the configuration could look something like this:

suites:
  - name: "suite-name"
    group: "group-name"
    endpoints:
      - ...

The suite would have a shared context (basically a map) that each endpoint would be able to write to/read from.

It would allow for much more advanced tests, the only problem is that it's quite a large feature and I haven't had the time to spare for a task of this size. That being said, you're free to give it a shot! If you have any questions, don't hesitate to ask :)

TwiN avatar Apr 03 '22 23:04 TwiN