The Lura Project Framework
The Lura Project framework, previously known as the KrakenD framework, is an open-source solution designed to build high-performance API Gateways with middleware integration. It serves as the core service of the KrakenD API Gateway.
Motivation
In the realm of microservices, clients often need to interact with backend services that aren't tailored for seamless UI integration. This can lead to complex client-side implementations burdened by the extensive data they need to process. Lura acts as an intermediary between the client and the backend services, simplifying this process. It aggregates data from multiple sources, streamlining it into a single endpoint, and transforming responses to suit the client's needs. This capability allows developers to minimize complexity while utilizing various middlewares and plugins for extended functionality, such as adding OAuth authorization or enhancing security.
Practical Example
Consider a mobile application developer needing to display a front page with data from four different backend service calls:
api.store.server/products
api.store.server/marketing-promos
api.users.server/users/{id_user}
api.users.server/shopping-cart/{id_user}
Normally, the mobile application would need to execute all these calls and manage the responses. However, Lura enables the mobile app to retrieve the necessary information via a single endpoint:
lura.server/frontpage/{id_user}
This capability allows Lura to aggregate the required data and deliver only pertinent fields, thus reducing response size and complexity for the client.
Repository Contents
The Lura Project repository offers the source code needed to build your own API Gateway or reuse components in other applications. It is built on the principles of the Unix philosophy, providing small, independent, and reusable components. For those needing a ready-to-use API Gateway, the KrakenD binary can be downloaded or built from source.
Library Usage
Lura is offered as a Go library, allowing developers to construct powerful APIs or proxy gateways within their applications. To utilize Lura, Go must be installed on the developer's system.
Here is a simple example of a Go application using Lura:
package main
import (
"flag"
"log"
"os"
"github.com/luraproject/lura/config"
"github.com/luraproject/lura/logging"
"github.com/luraproject/lura/proxy"
"github.com/luraproject/lura/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)
}
Developers can explore the Lura framework in more depth through its [documentation] and various resources available on its website.
Configuration and Benchmarks
Developers can navigate the [Lura config file] to tailor their setup according to project needs. Additionally, they can review benchmark results to assess the performance of different Lura components.
Contributing
The Lura Project welcomes contributions, whether through suggestions, bug reports, or code enhancements. Contributors are encouraged to open issues, join discussions, and submit pull requests for review.
Stay Connected
For updates, discussions, or questions, developers can follow Lura on Twitter, join their Slack channel, or explore extensive documentation provided by the project.
Enjoy exploring the capabilities of the Lura framework!