Skip to content
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

Proposal - Capture the X-Api-Info-Location header on all broker requests #66

Closed
vorbidan opened this issue Jun 8, 2019 · 8 comments
Closed
Labels

Comments

@vorbidan
Copy link
Contributor

vorbidan commented Jun 8, 2019

What

Add infoLocation to HTTP context. This will allow to obtain the foundation details if required.

How

Code untested
Example of brokerapi/middlewares/api-info-location-header.go

const (
	infoLocationKey = "infoLocation"
)

func AddInfoLocationToContext(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		infoLocation := req.Header.Get("X-Api-Info-Location")
		newCtx := context.WithValue(req.Context(), infoLocationKey, infoLocation)
		next.ServeHTTP(w, req.WithContext(newCtx))
	})
}

Update api to add MiddlewareFunc to the chain:

[...]
router.Use(middlewares.AddInfoLocationToContext)
[...]
@cf-gitbot
Copy link
Member

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/166560386

The labels on this github issue will be updated when the story is started.

@winnab
Copy link
Contributor

winnab commented Jun 10, 2019

Thanks @vorbidan! For prioritization, can you give a bit more detail about how and how soon you are hoping to use this? The X-Api-Info-Location was removed from the OSBAPI spec, so it would be great to hear more about the reason for brokerapi to start accepting it.

@vorbidan
Copy link
Contributor Author

vorbidan commented Jun 10, 2019

Thank you for your reply @winnab, I was not aware that it has been specifically removed from the OSBAPI spec, even though I could not find it there... I found the discussion about removing the "CFisms" from the OSBAPI, but could not really link it to what came out of it, specifically for the X-Api-Info-location
Coming from the Java world and Spring Cloud Open Service Broker and the fact that it is still a part of the implementation in the latest release, I missed it in the Go ...
How would one "know" what platform is invoking the Service Broker? Should it be a part of the context?

@winnab
Copy link
Contributor

winnab commented Jun 12, 2019

It seems that, according to the spec, it's possible to identify the "type" of the originating platform by inspecting either the X-Broker-API-Originating-Identity or the requests context.platform. That would inform your broker that the platform sending the request is a "cloudfoundry" platform.

Is that enough? Or are you looking for ways to ping back the platform or differentiate between multiple CFs?

@vorbidan
Copy link
Contributor Author

The idea is to be able to ping back the platform.

@winnab
Copy link
Contributor

winnab commented Jun 14, 2019

Ok, makes sense. Would you like to do a pull request for this work? We'd be happy to review.

@vorbidan
Copy link
Contributor Author

Done.
#67

gabrielecipriano pushed a commit that referenced this issue Jun 26, 2019
@kirederik
Copy link
Contributor

Thanks!

It is not available on v5.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants