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

PoC using redirect #16

Merged
merged 5 commits into from
Jun 2, 2020
Merged

PoC using redirect #16

merged 5 commits into from
Jun 2, 2020

Conversation

joselsegura
Copy link
Collaborator

Description

Just a PoC for the smart-proxy service using HTTP redirects.

This solution doesn't cache anything, so the final smart-proxy will look very different from this implementation.

Fixes #15

Type of change

  • New feature (non-breaking change which adds functionality)

Testing steps

Regular CI, no new tests at the moment

@codecov-commenter
Copy link

codecov-commenter commented May 29, 2020

Codecov Report

Merging #16 into master will increase coverage by 0.90%.
The diff coverage is 23.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #16      +/-   ##
==========================================
+ Coverage   19.40%   20.31%   +0.90%     
==========================================
  Files           9        9              
  Lines         438      507      +69     
==========================================
+ Hits           85      103      +18     
- Misses        341      391      +50     
- Partials       12       13       +1     
Impacted Files Coverage Δ
server/errors.go 0.00% <0.00%> (ø)
server/server.go 20.00% <8.51%> (-9.34%) ⬇️
server/endpoints.go 60.00% <52.38%> (+17.14%) ⬆️
smart_proxy.go 30.15% <100.00%> (+1.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 61b1df1...c3f6ccc. Read the comment docs.

Copy link
Collaborator

@tisnik tisnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but the results will need to be handled correctly later

server/server.go Outdated Show resolved Hide resolved
Copy link

@Serhii1011010 Serhii1011010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, I just don't like listing endpoints in each service, probably we could use prefixes, like

/api/v1/aggregator/* -> redirect to aggregator service
/api/v1/content/* -> redirect to content service

server/server.go Outdated Show resolved Hide resolved
Copy link

@natiiix natiiix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I don't see any significant issue 👍

server/server.go Outdated
}

// genericHandle
func (server HTTPServer) genericContentServiceRedirect(writer http.ResponseWriter, request *http.Request) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, genericAggregatorRedirect, and genericContentServiceRedirect are almost the same function, so maybe it could be something like

func (server HTTPServer) redirectTo(baseURL string) func(http.ResponseWriter, *http.Request)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@tisnik
Copy link
Collaborator

tisnik commented May 29, 2020

Looks good overall, I just don't like listing endpoints in each service, probably we could use prefixes, like

/api/v1/aggregator/* -> redirect to aggregator service
/api/v1/content/* -> redirect to content service

the whole redirect things are basically throwaway code anyway

@joselsegura
Copy link
Collaborator Author

I added a new function able to perform the request to the aggregator/content-service and then response back to the client

server/server.go Outdated Show resolved Hide resolved
@joselsegura joselsegura merged commit edd3768 into RedHatInsights:master Jun 2, 2020
@joselsegura joselsegura deleted the redirect_based_poc branch September 27, 2021 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a PoC version of the service
6 participants