-
Notifications
You must be signed in to change notification settings - Fork 564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why am I getting Error #01: Invalid status code? #102
Comments
The status 0 is a known 'feature' of the cache package included in the gin example (https://github.com/devopsfaith/krakend/blob/master/examples/gin/main.go#L68) Regarding the bigger than 200 status: by default, the gateway will always send a HTTP status 200 if the backend returns a 200 or a 201, and a 500 for any status above 400 https://github.com/devopsfaith/krakend/blob/master/proxy/http_status.go You can inject your own cheers! |
@kpacha do you have an example or a documentation for that? I read the code and it did not look very trivial to inject my own I would need to use And then will I be able to just get the generated proxy and do Thanks! |
check out the tests and the krakend-ce repo for examples of how to build the proxy stack. if you are not using the default factories, you must go with the 'explicit' constructors... something like this:
The |
Yuhu! Getting there! One last question @kpacha : is there a way to have access to the original headers of the responses (generated by my services) when injecting a I was able to figure out that this was the main handler I had to work on and inject to get the result I need thanks to your help 👍 My goal here is still to be able to decide what kind of status I want to return to the client (e.g. to be able to return a 201 when something was created as much as a 409 if there were a conflict). So far, without access to the list of headers from the requests, the only thing I could do is to modify all the responses from the services and let them return some additional information about what they did and what happened, then decide what status to set and after blacklist this additional data. I am curious, how did you imagined and designed Krakend to be used for this kind of scenario? I would really like to follow the idea and the design :) |
Checkout If You would like to wait till monday, I would like to prepare pull request for this. |
I have some minor remarks here: 1- the 2- as @bartoszgolek commented, the 3- even when your backend headers arrive to the As a final note, we created the KrakenD to be used as a pure, state-less API gateway (http://www.krakend.io/blog/what-is-an-api-gateway/). So I'm not sure if your use case fits in that classification. But this doesn't mean you shouldn't do it. |
I have created POC for this: bartoszgolek@630996f It's not complete, just showing the way of creating ability to manage merging |
here you have the complete PoC I was working on two months ago: https://github.com/devopsfaith/krakend/blob/raw_encoding/proxy/merging.go |
@adriendomoison , @bartoszgolek, please check this PR: #103 |
Hi, so long story short, if I want to send the response the service is providing to the user through the krakend gateway, I need to inject code? |
you can use or you can use |
@kpacha I can use the |
This issue was marked as resolved a long time ago and now has been automatically locked as there has not been any recent activity after it. You can still open a new issue and reference this link. |
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.
(I still get the response body I expected)
Then doing the request again:
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:
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:
go code:
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! 👍
The text was updated successfully, but these errors were encountered: