From 5e1a59c38497c5d44fdc5a320ecb500b20fa27f1 Mon Sep 17 00:00:00 2001 From: Danny Piper Date: Mon, 4 Mar 2024 19:56:28 +0000 Subject: [PATCH] feat: added private routing --- backend/src/cache_client.rs | 2 +- kube_cache/server/cache.go | 6 +++--- kube_cache/server/index.go | 40 ++++++++++++++++++++++--------------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/backend/src/cache_client.rs b/backend/src/cache_client.rs index fca0d7c..ecdd161 100644 --- a/backend/src/cache_client.rs +++ b/backend/src/cache_client.rs @@ -86,7 +86,7 @@ impl CacheClient { /// /// If the REST server connection fails, or if the output is an error (like 404), then this will return an Err. pub async fn get_recipe_by_id(&self, id1: Uuid, id2: Uuid) -> Result { - let res = reqwest::get(self.url.join(format!("kubeRecipeByIds/{}/{}", id1, id2).as_str()).unwrap()).await?.text().await?; + let res = reqwest::get(self.url.join(format!("private/kubeRecipeByIds/{}/{}", id1, id2).as_str()).unwrap()).await?.text().await?; Ok(serde_json::from_str(&res)?) } } diff --git a/kube_cache/server/cache.go b/kube_cache/server/cache.go index 075ee1d..8a02adb 100644 --- a/kube_cache/server/cache.go +++ b/kube_cache/server/cache.go @@ -26,11 +26,11 @@ func New(metrics *metrics.Metrics, database *model.Database, ai *aiStuff.KubeAi) func (s *Server) Use(engine *gin.Engine) { engine.GET("/cache_metrics", s.CacheMetrics) engine.GET("/kubes", s.GetAllKubes) - engine.GET("/kubeRecipes", s.GetAllKubeRecipes) engine.GET("/kubeById/:id", s.GetKube) + engine.GET("/kubeRecipes", s.GetAllKubeRecipes) engine.GET("/kubeImageById/:id", s.GetKubeImage) - engine.GET("/kubeImageByIdNew/:id", s.RegenerateImage) - engine.GET("/kubeRecipeByIds/:id1/:id2", s.GetKubeRecipe) + engine.GET("/private/kubeImageByIdNew/:id", s.RegenerateImage) + engine.GET("/private/kubeRecipeByIds/:id1/:id2", s.GetKubeRecipe) // index engine.GET("/", s.Index) diff --git a/kube_cache/server/index.go b/kube_cache/server/index.go index 7a26a46..abd9657 100644 --- a/kube_cache/server/index.go +++ b/kube_cache/server/index.go @@ -45,7 +45,7 @@ func (s *Server) IndexPost(c *gin.Context) {

New Kube: %s

Back

%s -

Regenerate Image

+

Regenerate Image

`, kube.Name, kube.Id, @@ -65,9 +65,9 @@ func (s *Server) Index(c *gin.Context) { kubesHtml := "" for _, kube := range kubes { kubesHtml += fmt.Sprintf(`
-

%s

- Regenerate Image - %s +

%s

+ Regenerate Image + %s
`, kube.Name, kube.Id, kube.Id, kube.Name) } @@ -95,23 +95,31 @@ func (s *Server) Index(c *gin.Context) { Kube Cache - +

Kube Cache

Endpoints

- +
+ +
+

+ Metrics are collected on Grafana, private endpoints requires the same proxy authentication. +

+
+

Create New Kube

%s

Kubes

-
+
%s

End of cache