Examples - groovylabs/lyre GitHub Wiki

In this file you will found some examples to create your own endpoints. If you have questions about how our syntax works, check here.

Endpoint written as little as possible:

YAML:

GET /ping:
    response:
        status: 200

endpoint1:
    method: GET
    path: /ping
    response:
        status: 200

JSON:

{
    "GET /ping" : {
        "response" : {
            "status" : 200
        }
    }
}

{
    "endpoint1" : {
        "method" : "GET",
        "path" : "/ping",
        "response" : {
            "status" : 200
        }
    }
}

Complete endpoint (with request body and idle/timeout):

YAML:

POST /ping:
    data: '{"request" : "Body request! (ATTENTION -> The send body needs be the same!)"}'
    consumes: 'application/json'
    response:
        status: 200
        header:
            custom-header: custom-response-header
        produces: application/json
        data: '{"response": "Test post endpoint successfully!"}'
    property:
        idle: 2000
        
endpoint1:
    method: POST
    path: /ping
    data: '{"request" : "Body request! (ATTENTION -> The send body needs be the same!)"}'
    consumes: 'application/json'
    response:
        status: 200
        header:
            custom-header: custom-response-header
        produces: application/json
        data: '{"response": "Test post endpoint successfully!"}'
    property:
        idle: 2000

JSON:

{
    "GET /ping" : {
        "data" : '{"request" : "Body request! (ATTENTION -> The send body needs be the same!)"}',
        "consumes" : "application/json",
        "response" : {
            "status" : 200,
            "header" : {
                "custom-header" : "custom-response-header"
            },
            "produces" : "applicaton/json",
            "data" : '{"response": "Test post endpoint successfully!"}'
        },
        "property" : { 
            "idle" : 2000
        }
    }
}

{
    "endpoint1" : {
        "method" : "GET",
        "path" : "/ping",
        "data" : '{"request" : "Body request! (ATTENTION -> The send body needs be the same!)"}',
        "consumes" : "application/json",
        "response" : {
            "status" : 200,
            "header" : {
                "custom-header" : "custom-response-header"
            },
            "produces" : "applicaton/json",
            "data" : '{"response": "Test post endpoint successfully!"}'
        },
        "property" : { 
            "idle" : 2000
        }
    }
}