GithubHelp home page GithubHelp logo

lgs / krakend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from luraproject/lura

0.0 1.0 0.0 958 KB

Ultra performant API Gateway with middlewares

Home Page: https://www.krakend.io

License: Other

Makefile 0.11% Go 99.61% Shell 0.28%

krakend's Introduction

Krakend logo

The KrakenD framework

Go Report Card Coverage Status GoDoc CII Best Practices Docker Pulls Slack Widget

An open framework to assemble ultra performance API Gateways with middlewares; core service of the KrakenD API Gateway.

Looking for the API gateway ready to use?

Site | Download | Build | Documentation | Blog

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.

KrakenD 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. KrakenD 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.

KrakenD 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, a 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) krakend.server/frontpage/{id_user}

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

Gateway

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

Visit the KrakenD website for more information.

What's in this repository?

The source code on which the KrakenD service core is built on. 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 want to build from source your API Gateway or if you want to reuse the components in another application.

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

Library Usage

KrakenD is presented as a go library that you can include in your own go application to build a powerful proxy or API gateway. In order to get you started several examples of implementations are included in the examples folder.

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

A ready to use example:

    package main

    import (
        "flag"
        "log"
        "os"

        "github.com/devopsfaith/krakend/config"
        "github.com/devopsfaith/krakend/logging"
        "github.com/devopsfaith/krakend/proxy"
        "github.com/devopsfaith/krakend/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/krakend/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, "[KRAKEND]")

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

        routerFactory.New().Run(serviceConfig)
    }

Visit the framework overview for more details about the components of the KrakenD.

Examples

The project KrakenD examples

  1. gin router
  2. mux router
  3. gorilla router
  4. negroni middlewares
  5. dns srv service discovery
  6. jwt middlewares
  7. httpcache based proxies

Configuration file

KrakenD config file

Benchmarks

Check out the benchmark results of several KrakenD 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.

If you want to contribute on the KrakenD API Gateway binary see the builder

Want more?

Enjoy the KrakenD!

krakend's People

Contributors

kpacha avatar taik0 avatar alombarte avatar foxcool avatar aldidana avatar dhontecillas avatar radykal-com avatar lennard-brinkhaus avatar lifeair avatar friedcalamari avatar tgracchus avatar adamaltman avatar neokeld avatar astroza avatar gonzaloserrano avatar pukoren avatar phumberdroz avatar smotrovalilit avatar suadev avatar x1ah avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.