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

Add a REST API output #9

Closed
andrewkroh opened this issue Feb 16, 2021 · 1 comment
Closed

Add a REST API output #9

andrewkroh opened this issue Feb 16, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@andrewkroh
Copy link
Member

Add an "output" that hosts the log messages via a REST API. The format of the returned document could be configurable via a Go text/template

Things that should be configurable:

  • path
  • content-type
  • paging style (timestamp based or http link headers)
  • body format template
  • tls settings
@marc-gr
Copy link
Contributor

marc-gr commented May 11, 2021

Since this is meant to fake an HTTP Server, it should be able to handle a serie of requests. Maybe having some sort of configuration file to define how to behave and what to return to a particular call could be nice.

I was thinking of something on the lines:

// A list of match rule definitions.
// It will match by the combination of method, path, query, and request_headers.
// If no method is defined, any will match, if no query is defined, any will match, etc.
// They will match in order, so more specific rules must go on top.
[
    {
        "method": "post",
        "path":"/foo/bar", // accepts a regexp
        "query": {}, // accepts a regexp in the values, the values must not be URL encoded.
        "request_headers": {}, // they can accept regexp in the values.
        "response_headers": {},
        "tls": {
            "cert": ""
            // ...
        },
        "body": [ // If more than 1 body is defined, 
                  // they will be returned in serie, first time the rule matches, will return body.0, second, body.1, etc. 
            "{ 
                // Not sure how text/template would work here other that functions, 
                // where would we get the values from? maybe from the request?
            }"
        ] 
    },
    // ...
]

When it comes to pagination, I think with this the users can define how it should behave and fake pagination as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants