MCPcopy
hub / github.com/luraproject/lura

github.com/luraproject/lura @v2.14.1 sqlite

repository ↗ · DeepWiki ↗ · release v2.14.1 ↗
1,173 symbols 4,396 edges 138 files 320 documented · 27%
README

The Lura Project framework

Go Report Card GoDoc CII Best Practices Slack Widget FOSSA Status

An open framework to assemble ultra performance API Gateways with middlewares; formerly known as KrakenD framework, and core service of the KrakenD API Gateway.

Motivation

Consumers of REST API content (specially in microservices) often query backend services that weren't coded for the UI implementation. This is of course a good practice, but the UI consumers need to do implementations that suffer a lot of complexity and burden with the sizes of their microservices responses.

Lura is an API Gateway builder and proxy generator that sits between the client and all the source servers, adding a new layer that removes all the complexity to the clients, providing them only the information that the UI needs. Lura acts as an aggregator of many sources into single endpoints and allows you to group, wrap, transform and shrink responses. Additionally it supports a myriad of middlewares and plugins that allow you to extend the functionality, such as adding Oauth authorization or security layers.

Lura not only supports HTTP(S), but because it is a set of generic libraries you can build all type of API Gateways and proxies, including for instance, an RPC gateway.

Practical Example

A mobile developer needs to construct a single front page that requires data from 4 different calls to their backend services, e.g:

1) api.store.server/products
2) api.store.server/marketing-promos
3) api.users.server/users/{id_user}
4) api.users.server/shopping-cart/{id_user}

The screen is very simple, and the mobile client only needs to retrieve data from 4 different sources, wait for the round trip and then hand pick only a few fields from the response.

What if the mobile could call a single endpoint?

1) lura.server/frontpage/{id_user}

That's something Lura can do for you. And this is how it would look like:

Gateway

Lura would merge all the data and return only the fields you need (the difference in size in the graph).

Visit the Lura Project website for more information.

What's in this repository?

The source code for the Lura project framework. It is designed to work with your own middleware and extend the functionality by using small, independent, reusable components following the Unix philosophy.

Use this repository if you want to build from source your API Gateway or if you want to reuse the components in another application.

If you need a fully functional API Gateway you can download the KrakenD binary for your architecture or build it yourself.

Library Usage

The Lura project is presented as a Go library that you can include in your own Go application to build a powerful proxy or API gateway. For a complete example, check the KrakenD CE repository.

Of course, you will need Go installed in your system to compile the code.

A ready to use example:

    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)
    }

Visit the framework overview for more details about the components of the Lura project.

Configuration file

Lura config file

Benchmarks

Check out the benchmark results of several Lura components

Contributing

We are always happy to receive contributions. If you have questions, suggestions, bugs please open an issue. If you want to submit the code, create the issue and send us a pull request for review.

Read CONTRIBUTING.md for more information.

Want more?

Enjoy Lura!

License

FOSSA Status

Extension points exported contracts — how you extend this code

Engine (Interface)
Engine defines the minimun required interface for the mux compatible engine [4 implementers]
router/mux/engine.go
Balancer (Interface)
Balancer applies a balancing stategy in order to select the backend host to be used [3 implementers]
sd/loadbalancing.go
Factory (Interface)
Factory creates proxies based on the received endpoint configuration. Both, factories and backend factories, create pro [3 …
proxy/factory.go
RequestWrapper (Interface)
RequestWrapper is an interface for passing proxy request between the lura pipe and the loaded plugins [3 implementers]
proxy/plugin.go
Router (Interface)
Router sets up the public layer exposed to the users [3 implementers]
router/router.go
EntityFormatter (Interface)
EntityFormatter formats the response data [2 implementers]
proxy/formatter.go
Logger (Interface)
Logger collects logging information at several levels [1 implementers]
logging/log.go
Subscriber (Interface)
Subscriber keeps the set of backend hosts up to date [1 implementers]
sd/subscriber.go

Core symbols most depended-on inside this repo

Error
called by 803
proxy/http.go
Get
called by 299
sd/register.go
Result
called by 188
proxy/merging.go
New
called by 95
router/router.go
Debug
called by 60
proxy/plugin/tests/error/main.go
Run
called by 50
router/router.go
Header
called by 46
router/gin/safecast.go
NewLogger
called by 41
logging/log.go

Shape

Function 614
Method 340
Struct 118
FuncType 40
Interface 40
TypeAlias 21

Languages

Go100%

Modules by API surface

config/config.go44 symbols
proxy/plugin/tests/logger/main.go40 symbols
proxy/plugin.go40 symbols
proxy/plugin/modifier_test.go30 symbols
proxy/merging.go28 symbols
config/parser.go27 symbols
proxy/plugin/modifier.go24 symbols
router/gin/endpoint_test.go23 symbols
proxy/formatter.go21 symbols
transport/http/server/server_test.go20 symbols
transport/http/client/status.go19 symbols
proxy/merging_test.go19 symbols

Dependencies from manifests, versioned

github.com/bytedance/gopkgv0.1.3 · 1×
github.com/bytedance/sonicv1.15.0 · 1×
github.com/bytedance/sonic/loaderv0.5.0 · 1×
github.com/cloudwego/base64xv0.1.6 · 1×
github.com/dimfeld/httptreemux/v5v5.5.0 · 1×
github.com/gabriel-vasile/mimetypev1.4.12 · 1×
github.com/gin-contrib/ssev1.1.0 · 1×
github.com/go-playground/localesv0.14.1 · 1×
github.com/go-playground/universal-translatorv0.18.1 · 1×

For agents

$ claude mcp add lura \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact