Giter Site home page Giter Site logo

luraproject / lura Goto Github PK

View Code? Open in Web Editor NEW
6.0K 115.0 552.0 1.52 MB

Ultra performant API Gateway with middlewares. A project hosted at The Linux Foundation

Home Page: https://luraproject.org

License: Other

Makefile 0.16% Go 99.84%
api-gateway microservice golang middleware router load-balancer gateway-api krakend proxies backend-services

lura's People

Contributors

aldidana avatar alombarte avatar anivanovic avatar armujahid avatar deepsource-autofix[bot] avatar dependabot[bot] avatar dhontecillas avatar fossabot avatar foxcool avatar friedcalamari avatar hummusim avatar kpacha avatar lennard-brinkhaus avatar lifeair avatar mariosnikolaou avatar moritzploss avatar moritzploss-k avatar mzanibelli avatar nodar963 avatar obokaman-com avatar phumberdroz avatar radykal-com avatar santiagolizardo avatar smotrovalilit avatar suadev avatar sumit-tembe avatar taik0 avatar tgracchus avatar wusphinx avatar x1ah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lura's Issues

Integrate with opencensus

Collect metrics and traces using the opencensus package, so we can use all the backend integrations.

It could replace/extend the newrelic, metrics and influxdb modules.

Error package when I do "make"

Hi,

I try to create a Docker image with the code Krakend (downloaded previously from repository). My Dockerfile is:

FROM golang:1.8

RUN mkdir /src
COPY . /src
WORKDIR /src
RUN make

Copy the code in /src directory and when execute make show me the next error:

Building krakend
Step 1/5 : FROM golang:1.8
 ---> 2cc9519276d1
Step 2/5 : RUN mkdir /src
 ---> Using cache
 ---> 61462aa77eaa
Step 3/5 : COPY . /src
 ---> a372b5629439
Removing intermediate container 126f42c6ae64
Step 4/5 : WORKDIR /src
 ---> 948ffe2627b2
Removing intermediate container 4a4166fed301
Step 5/5 : RUN make
 ---> Running in 130fabaf2e90
go get -u github.com/gin-gonic/gin
go get -u github.com/spf13/viper
go get -u github.com/op/go-logging
go get -u github.com/gorilla/mux
go get -u github.com/clbanning/mxj/x2j
go fmt ./...
go test -cover _/src/config _/src/config/viper _/src/core _/src/encoding _/src/logging _/src/logging/gologging _/src/proxy _/src/router _/src/router/gin _/src/router/gorilla _/src/router/mux _/src/sd _/src/sd/dnssrv
Makefile:15: recipe for target 'test' failed
can't load package: package _/src/config: cannot find package "_/src/config" in any of:
	/usr/local/go/src/_/src/config (from $GOROOT)
	/go/src/_/src/config (from $GOPATH)
can't load package: package _/src/config/viper: cannot find package "_/src/config/viper" in any of:
	/usr/local/go/src/_/src/config/viper (from $GOROOT)
	/go/src/_/src/config/viper (from $GOPATH)
can't load package: package _/src/core: cannot find package "_/src/core" in any of:
	/usr/local/go/src/_/src/core (from $GOROOT)
	/go/src/_/src/core (from $GOPATH)
can't load package: package _/src/encoding: cannot find package "_/src/encoding" in any of:
	/usr/local/go/src/_/src/encoding (from $GOROOT)
	/go/src/_/src/encoding (from $GOPATH)
can't load package: package _/src/logging: cannot find package "_/src/logging" in any of:
	/usr/local/go/src/_/src/logging (from $GOROOT)
	/go/src/_/src/logging (from $GOPATH)
can't load package: package _/src/logging/gologging: cannot find package "_/src/logging/gologging" in any of:
	/usr/local/go/src/_/src/logging/gologging (from $GOROOT)
	/go/src/_/src/logging/gologging (from $GOPATH)
can't load package: package _/src/proxy: cannot find package "_/src/proxy" in any of:
	/usr/local/go/src/_/src/proxy (from $GOROOT)
	/go/src/_/src/proxy (from $GOPATH)
can't load package: package _/src/router: cannot find package "_/src/router" in any of:
	/usr/local/go/src/_/src/router (from $GOROOT)
	/go/src/_/src/router (from $GOPATH)
can't load package: package _/src/router/gin: cannot find package "_/src/router/gin" in any of:
	/usr/local/go/src/_/src/router/gin (from $GOROOT)
	/go/src/_/src/router/gin (from $GOPATH)
can't load package: package _/src/router/gorilla: cannot find package "_/src/router/gorilla" in any of:
	/usr/local/go/src/_/src/router/gorilla (from $GOROOT)
	/go/src/_/src/router/gorilla (from $GOPATH)
can't load package: package _/src/router/mux: cannot find package "_/src/router/mux" in any of:
	/usr/local/go/src/_/src/router/mux (from $GOROOT)
	/go/src/_/src/router/mux (from $GOPATH)
can't load package: package _/src/sd: cannot find package "_/src/sd" in any of:
	/usr/local/go/src/_/src/sd (from $GOROOT)
	/go/src/_/src/sd (from $GOPATH)
can't load package: package _/src/sd/dnssrv: cannot find package "_/src/sd/dnssrv" in any of:
	/usr/local/go/src/_/src/sd/dnssrv (from $GOROOT)
	/go/src/_/src/sd/dnssrv (from $GOPATH)
make: *** [test] Error 1
ERROR: Service 'krakend' failed to build: The command '/bin/sh -c make' returned a non-zero code: 2

I tried it in my local machine and get the same error. Is possible the Makefile don't work correctly?

Thanks!

About the pricing

Hi,

I just found your project and it looks very interesting.
I have a question though: does the pricing on the feature page apply to the open-source version too? I mean, with the open-source version can we have as much nodes as we need or this only apply for the cloud? It's a bit confusing.

Also, can we handle consumers and give them credentials to consume our endpoints?

Thanks.

NopLogger

In order to avoid extra work in some scenarios, a NopLogger implementation of the Logger interface is required

Suggestions / New Features

Hi guys,

Hope you are all well !

I am giving a quick look at krakend and it inspired me the following notes that I wanted to share with you. The idea is to get your point of view/feedback about the relevancy of these suggestions.

Today, I have 3 problems :

  1. cannot find an easy to use web admin to test or create pipeline flows like proposed by krakend
  2. create resilient and parallel pipelines aggregating several inputs with an high QPS
  3. vertical and horizontal scaling of these aggregated micro-services

About the API Gateway:

Front-end/Admin-UI:

This message is just to share with you how I see a krakend evolving.
Have a nice day ! Viva la vida a barcelona ! :-)

ps. Is the krakend web form open sourced ?

Cheers,
Richard

proxy metadata and cookie

Hi,

Using Krakend to serve html content, my servers often send Set-Cookie headers.
I often have response headers like:

Set-Cookie: cookieName=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
Set-Cookie: cookieName2=value; Path=/; Max-Age=3600

To forward those cookies, I am using the Response.Metadata field of proxy/proxy.go, joining cookie headers using:

var response proxy.Response
response.Metadata["Set-Cookie"] = strings.Join(resp.Headers["Set-Cookie"], ",")

and setting the header back to with

for header, value := range response.Metadata {
    c.Header(header, value)
}

The problem with this approach is that having a , in the Set-Cookie header, only the first cookie is forwarded.

I was thinking of updating the Metadata type to either []string to match the http.Header type or interface{} to allow any users to store metadata in any format.

What do you think?

How to debug?

Hi,

I created a karkend.json file with the designer and used docker install method + docker-compose as in the example to run the API's gateway.

When I am testing using Postman, I get an error 500 with the body being "Unexpected 'B'".

There is no error in the console and I could not find any resources on the web, what could I do to debug this issue and have more information about what's going on?

Thank you ๐Ÿ‘

AsyncMerging: combine the partial responses as they arrive

For N backends, the merging middleware is waiting for the slowest one and then combining all the received partial responses (hopefully, N).

The gateway should keep a 'dirty copy' of the merged response and a couple of queues (or buffered channels) for the new responses and errors and then merge them with the accumulator as soon as they arrive (and they hit the top of the queue).

The new interface could support implementations of the former one by adding some kind of adapter between both.

Add dns-based service discovery

It is not a problem right now but any user would tend to declare the backend services using their DNS name. I think the service could scratch some milliseconds in the current implementation if it does the DNS-resolution and balancing itself. If the KrakenD service is doing it the requests will go directly to the IP and port where the backend listens with no additional network activity out of the gateway and backend scope, reducing extra hops and round trips.

Adding a DNS-based service discovery would be the easiest way of showing how to implement the interfaces of the sd package in order to clear the path for future integrations with other service discovery systems. Of course this is an enhancement since one can add an entry in /etc/hosts with the backend IP or similar strategy but of course this is not always convenient.

Thanks

Add router render registry

So the render of each endpoint could be picked by name in the config file (the current implementation just supports JSON rendering)

Add string encoder

So responses could be composed by aggregating data from backends serving text/plain

krakend cli / github access token / add custom headers

Hi,

Hope you are all well !

1. Krakend CLI

I was not able not find the executable/binary, mentioned in your documentation, http://www.krakend.io/docs/overview/usage/, with the output name: krakend. Only the set of examples (like gin) seems to be available. That's quite annoying as I wanted to try Krakend with the CLI version first.

Is it something available as open source ? that would be awesome for test purposes.

2. Append custom headers

Also, is it possible to add custom headers ? For example, I would like to get returned the topics property for my github search requests. It would imply to add the following header ('Accept', 'application/vnd.github.mercy-preview+json'). (ref: https://developer.github.com/v3/search/#search)

For the code search, I would be required to pass the personal token.

How Krakend is managing authentication to third-party providers for the moment ?

Is it possible to add an example to the krakend-playground with a small group of endpoints aggregating some github search results, via the api v3, for a query submitted by POST or GET (repo,code,commits, issues) ?

3. Aggregate many infos/sources for developers

Last question, how many of these possible engines could aggregate with krakend compared to searx ? https://github.com/asciimoo/searx/blob/master/searx/settings.yml

I would like to create a cli based utility to aggregate dev oriented from several providers like github (starred), stackoverflow, reddit and hackernews (much more like howdoi). It would return some insights by parsing some stderr or logs, or more directly by entering a query.

refs.

  • ferret (golang) Ferret is a search engine that unifies search results from Github, Slack, Trello and more
  • limo (golang) a CLI for managing/searching your starred Git repositories
  • searx (python) hackable meta search engine
  • searx admin (python), allowing to manage/edit aggregation rules

engineslist

Cheers,
Richard

conditional sub-requests / back-end registry / openapi/raml imports

Hey,

Just creating a new issue for the additional questions/suggestions I had... ^^

1. How would u see to trigger some conditional sub-requests (in serie or in parallel) ? the idea would be to add some flow based sub-requests per backend or endpoint.

2. How would you see to preload some backends/providers profiles and hook them in the config files with backend_id ?

Cheers,
Richard

fatal error: concurrent map writes when multiple backends

krakend[4734]: goroutine 1053 [running]:
krakend[4734]: runtime.throw(0xc8a990, 0x15)
krakend[4734]: /var/opt/go/1.10/src/runtime/panic.go:619 +0x81 fp=0xc42061d920 sp=0xc42061d900 pc=0x42c921
krakend[4734]: runtime.mapassign_faststr(0xb74440, 0xc4205adda0, 0xc84b14, 0xd, 0xc4201eacb0)
krakend[4734]: /var/opt/go/1.10/src/runtime/hashmap_fast.go:703 +0x3e9 fp=0xc42061d990 sp=0xc42061d920 pc=0x40d529
krakend[4734]: ioki.pl/krakend-ce/oauth1.newMiddleware.func1.1(0xd225c0, 0xc4201a0840, 0xc4205ca140, 0xc4205f85a6, 0xc4205f85c0, 0xc42064ac78)
krakend[4734]: /home/bartoszgolek/go/src/ioki.pl/krakend-ce/oauth1/backend.go:35 +0x12c fp=0xc42061dbc0 sp=0xc42061d990 pc=0x96f96c
krakend[4734]: ioki.pl/krakend-ce/vendor/github.com/devopsfaith/krakend-metrics.NewProxyMiddleware.func1.1(0xd225c0, 0xc4201a0840, 0xc4205ca140, 0x0, 0x0, 0x50)
krakend[4734]: /home/bartoszgolek/go/src/ioki.pl/krakend-ce/vendor/github.com/devopsfaith/krakend-metrics/proxy.go:56 +0xd9 fp=0xc42061dc88 sp=0xc42061dbc0 pc=0x95de49
krakend[4734]: ioki.pl/krakend-ce/vendor/github.com/devopsfaith/krakend/proxy.newLoadBalancedMiddleware.func1.1(0xd225c0, 0xc4201a0840, 0xc4205ca0f0, 0x412468, 0x10, 0xba0580)
krakend[4734]: /home/bartoszgolek/go/src/ioki.pl/krakend-ce/vendor/github.com/devopsfaith/krakend/proxy/balancing.go:59 +0x304 fp=0xc42061ddc0 sp=0xc42061dc88 pc=0x6dba54
krakend[4734]: ioki.pl/krakend-ce/vendor/github.com/devopsfaith/krakend/proxy.NewRequestBuilderMiddleware.func1.1(0xd225c0, 0xc4201a0840, 0xc42049ca50, 0xc4201a0840, 0xc4203620d0, 0xc4201282d0)
krakend[4734]: /home/bartoszgolek/go/src/ioki.pl/krakend-ce/vendor/github.com/devopsfaith/krakend/proxy/http.go:87 +0x1df fp=0xc42061deb8 sp=0xc42061ddc0 pc=0x6dcd3f
krakend[4734]: ioki.pl/krakend-ce/vendor/github.com/devopsfaith/krakend/proxy.requestPart(0xd22640, 0xc420020f60, 0xc4202dd770, 0xc42049ca50, 0xc420020fc0, 0xc420021020)
krakend[4734]: /home/bartoszgolek/go/src/ioki.pl/krakend-ce/vendor/github.com/devopsfaith/krakend/proxy/merging.go:61 +0x84 fp=0xc42061dfb0 sp=0xc42061deb8 pc=0x6dad14
krakend[4734]: runtime.goexit()
krakend[4734]: /var/opt/go/1.10/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42061dfb8 sp=0xc42061dfb0 pc=0x459921
krakend[4734]: created by ioki.pl/krakend-ce/vendor/github.com/devopsfaith/krakend/proxy.NewMergeDataMiddleware.func1.1

I think it is connected to:
https://github.com/devopsfaith/krakend/pull/98/commits/4fbd601e5f5f7799cd0e693f7649d7f0ee0db076

I've found that better solutino would be:
https://github.com/devopsfaith/krakend/commit/079376adbc655473d3eabd12e6c91581bdb77597

Explicit header on partial responses

We are currently relying on the cache headers to know if all the backends response completed (presence) or something failed (absence).

It could be helpful to include an explicit header to inform the client that the response is complete or not.

Maybe something like X-KrakenD-Completed: true|false ?

It might add some unnecessary bytes but IMO is worth it.

Accept non-objects in the backends response

Currently KrakenD is only processing responses from backends that return objects. Even returning objects is the usual case, it would be nice to support non-object responses such as lists. E.g:

[ "some", "thing" ]

Add `Accept` header to backend requests

KrakenD does not add the Accept header to the requests it's sending to each backend.

possible options:

  1. inject a custom value from the config
  2. inject the custom value the client sent to the KrakenD endpoint
  3. inject a value depending on the configured decoder
  4. inject the value */* by default

[question] handle parameters not starting with /

Hi,

I am using krakend to serve both api and static content.
As . we are using webpack to generate our static files, it results in paths like:

/index.html
/app.<sum>.js
/app.<sum2>.css
/vendor.<sum3>.js

and our API endpoint may look like: /api/<something>
Ideally, I would like to have configuration file like

  "endpoint": "/api/{path}",
  "method": "GET",
  "backend": [{
    "url_pattern": "/api/{path}",
    "host": [
      "http://api:8080"
    ]
  }]
},
{
  "endpoint": "/{file}",
  "method": "GET",
  "backend": [{
    "url_pattern": "/{file}",
    "host": [
      "http://localhost:8080"
    ]
  }]

or

      "endpoint": "/api/{path}",
      "method": "GET",
      "backend": [{
        "url_pattern": "/api/{path}",
        "host": [
          "http://api:8080"
        ]
      }]
    },
    {
      "endpoint": "/app.{file}.css",
      "method": "GET",
      "backend": [{
        "url_pattern": "/app.{file}.css",
        "host": [
          "http://localhost:8080"
        ]
      }]
    },
    {
      "endpoint": "/",
      "method": "GET",
      "backend": [{
        "url_pattern": "/",
        "host": [
          "http://localhost:8080"
        ]
      }]
    }

In the first case, I get an error of panic: wildcard route ':file' conflicts with existing children in path '/:file', in the second, I get ERROR:Fatal error during config init: Too many output params! input: map[file:<nil>], output: [file]

The first error is raised by the gin router and it looks like there is nothing much to do about it, for the second error, It seems related to the use of endpointURLKeysPattern that includes a leading / compared to simpleURLKeysPattern.
What would be the impact of always parsing using simpleURLKeysPattern ?

DNS Lookup Config

I've been trying to get DNS working as I have a Consul instance running on another box for service discovery/lookup.

When I run the command
$dig +short jsonplaceholder.service.consul -p 8600
from the VM where KrakenD is deployed I get back:
https://jsonplaceholder.typicode.com/

Which is expected. I've tried many different values in the KrakenD config to get the DNS lookup to work like:
"hosts": [
{
"sd": "dns",
"host": "jsonplaceholder.service.consul"
},
{
"sd": "dns",
"host": "jsonplaceholder.service.consul -p 8600"
},
{
"sd": "dns",
"host": "jsonplaceholder.service.consul:8600"
},
{
"sd": "dns",
"host": "jsonplaceholder.service.consul",
"port":8600
}
]

In the endpoints I've tried all combinations listed above as well as adding a 'port' key/value within the endpoint as well all without success.

Each time i try to make a REST call it comes back wtih

[GIN] 2018/05/03 - 17:49:40 | 500 | 130.601ยตs | 161.97.208.40 | GET /users
Error #1: no hosts available

Here's the full config file:
{
"version": 2,
"extra_config": {
"github_com/devopsfaith/krakend-gologging": {
"level": "DEBUG",
"prefix": "[KRAKEND]",
"syslog": false,
"stdout": true
},
"github_com/devopsfaith/krakend-etcd": {
"dial_timeout": "5s",
"dial_keepalive": "30s",
"header_timeout": "1s"
},
"krakendesigner": {
"endpoint_defaults": {
"github.com/devopsfaith/krakend-ratelimit/juju/router": {
"maxRate": 0,
"clientMaxRate": 0
}
}
}
},
"sd_providers": {
"providers": {
"static": true,
"dns": true
},
"hosts": [
{
"sd": "dns",
"host": "jsonplaceholder.service.consul"
},
{
"sd": "dns",
"host": "jsonplaceholder.service.consul -p 8600"
},
{
"sd": "dns",
"host": "jsonplaceholder.service.consul:8600"
},
{
"sd": "dns",
"host": "jsonplaceholder.service.consul",
"port":8600
}
]
},
"endpoints": [
{
"endpoint": "/users",
"method": "GET",
"concurrent_calls": 1,
"extra_config": {
"github_com/devopsfaith/krakend-httpsecure": {
"disable": true,
"allowed_hosts": [],
"ssl_proxy_headers": {}
},
"github.com/devopsfaith/krakend-ratelimit/juju/router": {
"maxRate": 0,
"clientMaxRate": 0
}
},
"backend": [
{
"url_pattern": "/users",
"extra_config": {
"github.com/devopsfaith/krakend-oauth2-clientcredentials": {
"is_disabled": true,
"endpoint_params": {}
}
},
"encoding": "json",
"sd": "dns",
"host": [
"jsonplaceholder.service.consul"
],
"disable_host_sanitize": true,
"is_collection": true,
"target": "",
"group": "users"
}
]
}
],
"max_idle_connections": 250,
"timeout": "3000ms",
"read_timeout": "0s",
"write_timeout": "0s",
"idle_timeout": "0s",
"read_header_timeout": "0s",
"cache_ttl": "300s",
"name": "test"
}

Thanks

reload config

figuring out, does krakend currently support reloading config files without restarting the krakend itself ?

for example :

krakend -c config.json --reload

Possibility - backend query within a backend query

Hi,

Is it possible to run a backend query within an another backend query..?
For example,
API Endpoint

  • Service A
    - Response received, having a for loop, iteration happens say 5 IDs, so 5 requests
    - call Service B for ID 1
    - call Service B for ID 2
    - call Service B for ID 3
    - call Service B for ID 4
    - call Service B for ID 5
    - Map and do final response manipulation
  • Service C
    • Response recieved

Finally manipulate response for all and sends back the response.
Not sure if this kind of support available. Documentation has stuff relatively straight forward like just call 2 or 3 services one by one..

Add support for gorilla/mux

The mux package is 'almost' compatible with the gorilla/mux and other 3rd party routers. Finishing the integration with this lib would make it easier for others to use and extend the framework.

Support for "shadow requests"

In order to be able to clone actual request for testing, it would be nice to support shadow requests.

It will require adding a new group of backends to the endpoint definition but without including them into the set of pipe branches observed by the merging proxy middleware.

proxy middleware register

Create a proxy middleware register (like the one in the encoding package) and a new proxy factory for building pipes as described in the endpoint and backend extra configurations.

Why am I getting Error #01: Invalid status code?

Hi, it me again, still new to Krakend ! ๐Ÿ’ƒ

When I do a request throug the gateway, I am getting a status code 0 (?) in my response when using the "gin example" of the repository.

api_gateway_1  | [GIN] 2018/03/15 - 07:49:49 |   0 |   85.720918ms |      172.20.0.1 | POST     /api/v1/users?create_profile=true
api_gateway_1  | Error #01: Invalid status code

(I still get the response body I expected)

Then doing the request again:

api_gateway_1  | [GIN] 2018/03/15 - 07:49:49 |   200 |   85.720918ms |      172.20.0.1 | POST     /api/v1/users?create_profile=true

The request is returning 200 while I am waiting for a 409, nothing is called and nothing is returned.

I then tried to use the example directly in the README.md (since it is an even simpler version using gin too) and I get better results:

api_user_1     | [GIN] 2018/03/15 - 07:57:21 | 201 |   86.655951ms |      172.20.0.1 | POST     /api/v1/users?create_profile=true
api_gateway_1  | [GIN] 2018/03/15 - 07:57:21 | 200 |   89.901626ms |      172.20.0.1 | POST     /api/v1/users?create_profile=true

But I get a 200 while I was expecting a 201 (?)
Then I tried to do the request again, it fails as expected but I get a 500 instead of the expected 409 with the message again:

api_user_1     | [GIN] 2018/03/15 - 07:57:28 | 409 |   51.846764ms |      172.20.0.1 | POST     /api/v1/users?create_profile=true
api_gateway_1  | [GIN] 2018/03/15 - 07:57:28 | 500 |   52.963005ms |      172.20.0.1 | POST     /api/v1/users?create_profile=true
api_gateway_1  | Error #01: Invalid status code

go code:

func main() {
	serviceConfig, err := config.NewParser().Parse("/etc/krakend/configuration.json")
	if err != nil {
		log.Fatal("ERROR:", err.Error())
	}
	serviceConfig.Debug = true
	serviceConfig.Port = 4200

	logger, err := logging.NewLogger("ERROR", os.Stdout, "[KRAKEND]")
	if err != nil {
		log.Fatal("ERROR:", err.Error())
	}

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

	routerFactory.New().Run(serviceConfig)
}

Why are the response I am getting inconsistent? How is it possible and what am I doing wrong here?

Thank you, I really value your time and I appreciate your help very much! ๐Ÿ‘

Add a cache to the mux example

The gin example demonstrates how to integrate a cache into the gin router adapter. It would be great to show how to do it with the other router adapters available in the framework.

Since the gorilla and the negroni frameworks use the basic mux implementation, selecting it for the first example will be useful for the community

FR: Configuration via API

I'd like to change the configuration via an API instead of loading and saving the configuration file (KrakenDesigner) or updating it manually to change/add endpoints.

It would also allow developers to integrate docker swarm/kubernetes to automatically register endpoints by creating services.

Add Nop encoder and render

So the backend response could be passed in the proxy.Response.Io to the new router render.

This new render must copy the contents of the proxy.Response.Io into the http.ResponseWriter instead of marshaling the proxy.Response.Data

Add support for martian

By supporting the martian lib, krakend will offer a very powerful verification, filter and manipulation layer for the net/http adapter.

Check here for more detals

Content-Length is not being proxied

Running the simplest example copied from Library Usage - the same exact code. With this configuration.json:

{
  "version": 2,
  "name": "My lovely gateway",
  "port": 8080,
  "host": [
    "http://127.0.0.1:8080"
  ],
  "endpoints": [
    {
      "endpoint": "/",
      "method": "POST",
      "backend": [
        {
          "host": [
            "http://127.0.0.1:8000"
          ],
          "encoding": "json"
        }
      ],
      "headers_to_pass": [
        "Content-Length",
        "Content-Type",
        "Accept",
        "Host",
        "User-Agent"
      ]
    }
  ]
}

I am not getting Content-Length on my CherryPy service. It's possible to reproduce with this request:

curl --fail -X POST -H 'Content-Type: application/json' -H 'Content-Length: 22' -H 'Accept: json' -d '{"text": "0000000000"}' 'http://localhost:8080' 

All other headers and content are proxied correctly. The problem is only with Content-Length.

Support for stub backend responses

In order to create health-check and other endpoints based on static data or even to complete the collected data from several backends, it would be nice to have an easy way to add a custom backend factory able to create a proxy.Response from the JSON definition included at the extra_config.

The feature introduces some very dangerous options that we must be aware of. From the top of my head:

  • it will add an extra merging branch in the pipe
  • this kind of backend responses will always succeed, so it could hide complete failures of the consumed backends due the existence of a single partial (from the stub backend)
  • it will pollute the config file of the GW, so it could affect the versioning.

Support for gRPC

Hi
First of all, thanks a lot for the great job. Do you have any plan to add support for gRPC routing as well. Can you share some ideas/solutions in here how to implement it so someone else can also help with that.

Thanks

Cannot use a host with path

When I specify a host with path in the configuration file, it causes a panic.

Here is an example.

  • This is a host without path. It's a valid host.

    https://api.github.com
    
  • This is a host with path. It causes errInvalidHost.

    https://api.twitter.com/1.1
    

As a workaround, I put the path into url_pattern.

{
  "url_pattern": "/1.1/statuses/home_timeline.json",
  "host": [
    "https://api.twitter.com"
  ]
}

However I feel it should be able to specify like below.

{
  "url_pattern": "/statuses/home_timeline.json",
  "host": [
    "https://api.twitter.com/1.1"
  ]
}

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.