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

feat(kuma-cp) redirect requests from gui server to api server #520

Merged
merged 2 commits into from
Jan 7, 2020

Conversation

jakubdyszkiewicz
Copy link
Contributor

Summary

Redirect requests from GUI on /api prefix to API Server. This simplifies setup since you don't have to coordinate exposing GUI and API server and configuring proper external address.

@jakubdyszkiewicz jakubdyszkiewicz requested review from a team and yskopets January 2, 2020 11:22
srv := Server{rt.Config().GuiServer}
srv := Server{
Config: rt.Config().GuiServer,
ApiServerPort: rt.Config().ApiServer.Port,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why ApiServerPort is not a part of Config ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved as a part of the configuration.

@@ -64,6 +76,21 @@ func (g *Server) Start(stop <-chan struct{}) error {
}
}

func (g *Server) apiHandler() (http.Handler, error) {
apiServerUrl, err := url.Parse(fmt.Sprintf("http://localhost:%d", g.ApiServerPort))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to hardcode it here instead of making it a part of configuration ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved as a part of the configuration.

if err := core_runtime.Add(rt, &srv); err != nil {
return err
}
return nil
}

type Server struct {
Config *gui_server.GuiServerConfig
Config *gui_server.GuiServerConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we deprecate the old ApiUrl field ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added deprecation.

@jakubdyszkiewicz jakubdyszkiewicz merged commit 0cbb2e1 into master Jan 7, 2020
@jakubdyszkiewicz jakubdyszkiewicz deleted the feature/redirect-gui-to-api branch January 7, 2020 12:43
@bloqhead
Copy link

bloqhead commented Jan 8, 2020

@yskopets @jakubdyszkiewicz what does this mean for the way I'm fetching the API and config? Is there anything I need to change or will it still work as is?

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.

None yet

3 participants