Skip to main content

Overview

This endpoint demonstrates a simple public API that doesn’t require authentication. It’s configured with a short cache TTL of 1 second. HTTP Method: GET
Endpoint: /public
Cache TTL: 1 second

What It Demonstrates

  • Public access without authentication
  • Custom cache configuration at the endpoint level
  • Simple backend proxy pattern

Request Example

curl http://localhost:8080/public

Expected Response

The endpoint returns hotel data from the backend:
{
  "id": 1,
  "name": "Hotel Example",
  "location": "City Name",
  "rating": 4.5,
  "destination_id": 123
}

Backend Configuration

This endpoint proxies to a single backend service:
  • Backend Host: http://fake_api (inherited from global config)
  • URL Pattern: /hotels/1.json
  • Timeout: 3000ms (inherited from global config)

KrakenD Configuration

{
  "@comment": "Feature: A public endpoint that requires no authentication",
  "cache_ttl": "1s",
  "endpoint": "/public",
  "backend": [
    {
      "url_pattern": "/hotels/1.json"
    }
  ]
}

Key Features

Cache Configuration

The endpoint overrides the global cache TTL (300s) with a custom value of 1s, making it useful for frequently updated public data.

No Authentication

Unlike /private/moderate and /private/custom endpoints, this endpoint has no auth/validator configuration, making it accessible to all clients.

Use Cases

  • Public API data that changes frequently
  • Status endpoints
  • Public information feeds
  • Health check endpoints with dynamic data

Build docs developers (and LLMs) love