A Linux Foundation project

Build your own API gateway in Go.

Lura is the open source framework for assembling high-performance, stateless API gateways from small, reusable components. The engine behind KrakenD.

go get github.com/luraproject/lura/v3
Why Lura

Simple, stateless and fast by design.

Lura is the engine of KrakenD and shares its philosophy: the gateway should be a thin, fast layer that does the API work once, so neither clients nor backends have to. Its design follows a short set of rules:

  • Reactive is key
  • Failing fast is better than succeeding slow
  • The simpler, the better
  • Everything is pluggable
  • Each request is processed in its own request-scoped context

Stateless

No database and no coordination between nodes. Every instance works on its own, so you scale by adding instances.

Declarative

The configuration describes the whole service: endpoints, backends and the middlewares on each of them. Behavior is data you keep in version control, not code to deploy.

Built once, served from memory

At start-up Lura reads the configuration and builds a pipe for every endpoint. Requests find their handler directly, so adding endpoints doesn't slow the gateway down.

Everything is pluggable

Routers, proxies and middlewares are Go interfaces. Choose the router, stack only the middlewares you need, or write your own.

Fail fast

Failing fast is better than succeeding slow. Every request runs in its own context with timeouts, and work that can no longer help the client is cancelled.

Not tied to HTTP

Lura is a set of Go libraries for Layer 7 gateways. The same building blocks serve other transports, such as an RPC gateway.

Aggregation: one request in, many backends out.

Backend services are rarely shaped the way a user interface needs them. A mobile front page might need four calls. With a gateway built on Lura, the client makes one call to lura.server/frontpage/{id_user}: Lura calls the backends concurrently, merges the responses and returns only the fields the screen uses.

Clients stay isolated from backend contracts, and backends no longer each handle shared concerns such as authentication or rate limiting: the gateway does it once.

api.store.server/products
api.store.server/marketing-promos
api.users.server/users/{id_user}
api.users.server/shopping-cart/{id_user}
One call through Lura instead of four A client makes one request, GET /frontpage/{id_user}, and receives 150 KB. Lura calls four backends concurrently: /products (300 KB), /marketing-promos (50 KB), /users/{id_user} (15 KB) and /shopping-cart/{id_user} (10 KB), then merges and trims the responses. 1 call · 150 KB 4 concurrent calls · 375 KB Clientmobile app GET /frontpage/{id_user} 150 KB GET /products 300 KB GET /marketing-promos 50 KB GET /users/{id_user} 15 KB GET /shopping-cart/{id_user} 10 KB
Get started

A gateway in one Go file.

Lura is a Go library you include in your own application. This program reads a configuration file and serves every endpoint it declares, using the gin router:

package main

import (
    "flag"
    "log"
    "os"

    "github.com/luraproject/lura/v3/config"
    "github.com/luraproject/lura/v3/logging"
    "github.com/luraproject/lura/v3/proxy"
    "github.com/luraproject/lura/v3/router/gin"
)

func main() {
    port := flag.Int("p", 0, "Port of the service")
    logLevel := flag.String("l", "ERROR", "Logging level")
    debug := flag.Bool("d", false, "Enable the debug")
    configFile := flag.String("c", "/etc/lura/configuration.json", "Path to the configuration filename")
    flag.Parse()

    parser := config.NewParser()
    serviceConfig, err := parser.Parse(*configFile)
    if err != nil {
        log.Fatal("ERROR:", err.Error())
    }
    serviceConfig.Debug = serviceConfig.Debug || *debug
    if *port != 0 {
        serviceConfig.Port = *port
    }

    logger, _ := logging.NewLogger(*logLevel, os.Stdout, "[LURA]")

    routerFactory := gin.DefaultFactory(proxy.DefaultFactory(logger), logger)

    routerFactory.New().Run(serviceConfig)
}
Components

Extend your gateway with components and middlewares.

Lura is built to be extended: features come as components and middlewares, small Go modules you stack in your own gateway. The ones below build against Lura v3. Today the KrakenD team, Lura's main contributor, maintains all of them, and each repository explains how to wire it in.

Security

Traffic

Logic and transformation

Backends and messaging

  • krakend-amqp

    AMQP (RabbitMQ) consumer, producer and async agent.

  • krakend-pubsub

    Publish/subscribe backends: Kafka, NATS, RabbitMQ and cloud queues.

  • krakend-lambda

    Calls AWS Lambda functions as backends.

Observability

Configuration and tooling

Built a component or middleware for Lura?

Add it to this list. The site is a single HTML file, so it takes one line: edit the page on GitHub and open a pull request with your module, its repository and a short description.

Prefer a ready-made gateway?

KrakenD Community Edition is built on Lura and ships with many of these components, assembled into a single binary you configure with a JSON file instead of Go code. It is available as a Docker Official Image:

docker run -it -p "8080:8080" krakend

Also as binaries and packages for several platforms: see downloads and the KrakenD Community Edition page.

Governance

A Linux Foundation project.

Lura has been hosted by the Linux Foundation since 2021, when the KrakenD team donated the framework (announcement). It is governed by its Technical Charter and follows the LF Projects Code of Conduct.

Technical Charter (PDF)

Adopted on April 14, 2021. It covers:

  1. Mission and scope of the project
  2. Technical Steering Committee
  3. TSC voting
  4. Compliance with policies
  5. Community assets
  6. General rules and operations
  7. Intellectual property policy
  8. Amendments
Community

Built in the open.

Issues

The preferred place for bugs, feature requests and questions.

Contributing

Pull requests are welcome. Discuss larger changes in an issue first.

Security

Report vulnerabilities privately, as the security policy explains.

Slack

Join #lura on the Gophers Slack.

Please don't contact individual project members for support.

Credits

The people behind Lura.

Founders

Lura began in 2016 as the KrakenD framework, created by Daniel López, Daniel Ortiz and Albert Lombarte, the founders of KrakenD.

The name

Proposed by Carmela Rubiños. Lura is Galician for squid, a fitting name for the engine of KrakenD, which is named after the Kraken, the giant sea creature of Norse legend. Lura is the Kraken's offspring, and its logo draws those many arms, each reaching a different backend.

The Linux Foundation

Scott Nicholas, of the Linux Foundation, facilitated the project's move to the Linux Foundation in 2021.

Launch partners

99P Labs (backed by Honda), Ardan Studios, Hepsiburada, Openroom, Postman, Skalena and Stayforlong supported the project's launch at the Linux Foundation in 2021 (announcement).

Contributors

Major contributions from David Hontecillas and Jorge Tarrero, and from everyone who has sent code, reviews and issues. Thank you.