From c9fd7baf9d0bc6e4a3bd80786de205ef341b4fbb Mon Sep 17 00:00:00 2001 From: "pakintada@gmail.com" Date: Fri, 9 Feb 2024 17:02:02 +0700 Subject: [PATCH] test expose style --- .../src/app/core/services/topping.service.ts | 26 +++++++++++-------- client/src/environments/environment.ts | 2 +- server/routers/auth.go | 6 +++++ server/routers/topping.go | 2 +- server/server.go | 2 ++ 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/client/src/app/core/services/topping.service.ts b/client/src/app/core/services/topping.service.ts index d70d158..f51350c 100644 --- a/client/src/app/core/services/topping.service.ts +++ b/client/src/app/core/services/topping.service.ts @@ -1,4 +1,4 @@ -import { HttpClient } from '@angular/common/http'; +import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable, count } from 'rxjs'; import { environment } from 'src/environments/environment'; @@ -64,14 +64,16 @@ export class ToppingService { let asyncCountry = await this._recipeService.getCurrentCountry(); country = getCountryMapSwitcher(asyncCountry); + let qParam = new HttpParams(); + qParam = qParam.append('country', country); + qParam = qParam.append('filename', filename); + return this._httpClient.get( - `${environment.api}/toppings/groups`, + `${environment.api}/toppover/groups`, { - params: { - country: country, - filename: filename, - }, + params: qParam, withCredentials: true, + responseType: 'json', } ); } @@ -84,14 +86,16 @@ export class ToppingService { let asyncCountry = await this._recipeService.getCurrentCountry(); country = getCountryMapSwitcher(asyncCountry); + let qParam = new HttpParams(); + qParam = qParam.append('country', country); + qParam = qParam.append('filename', filename); + return this._httpClient.get( - `${environment.api}/toppings/lists`, + `${environment.api}/toppover/lists`, { - params: { - country: country, - filename: filename, - }, + params: qParam, withCredentials: true, + responseType: 'json', } ); } diff --git a/client/src/environments/environment.ts b/client/src/environments/environment.ts index 16ac628..baf010b 100644 --- a/client/src/environments/environment.ts +++ b/client/src/environments/environment.ts @@ -1,4 +1,4 @@ export const environment = { production: true, - api: 'https://recipe.taobin.io:8090/api', + api: 'http://10.11.77.50:5555', }; diff --git a/server/routers/auth.go b/server/routers/auth.go index fee4cf9..fd9c7f3 100644 --- a/server/routers/auth.go +++ b/server/routers/auth.go @@ -5,6 +5,7 @@ import ( "crypto/rand" "encoding/base64" "encoding/json" + "fmt" "net/http" "net/url" "recipe-manager/config" @@ -60,6 +61,9 @@ func (ar *AuthRouter) Route(r chi.Router) { var redirectTo string var kind string state := r.URL.Query().Get("state") + + fmt.Println("url query", r.URL.Query()) + if state == "" { http.Error(w, "State not found", http.StatusBadRequest) return @@ -71,6 +75,8 @@ func (ar *AuthRouter) Route(r chi.Router) { return } + fmt.Println("val", val) + redirectTo = val["redirect_to"] kind = val["kind"] diff --git a/server/routers/topping.go b/server/routers/topping.go index 730d7e2..7a96f97 100644 --- a/server/routers/topping.go +++ b/server/routers/topping.go @@ -30,7 +30,7 @@ func (tr *ToppingRouter) Route(r chi.Router) { // check incoming request fmt.Println("topping router", r.Routes()) - r.Route("/toppings", func(r chi.Router) { + r.Route("/toppover", func(r chi.Router) { r.Get("/groups", tr.GetToppingGroups) diff --git a/server/server.go b/server/server.go index 26392b1..fd961f9 100644 --- a/server/server.go +++ b/server/server.go @@ -142,6 +142,8 @@ func (s *Server) createHandler() { }) + // routers.NewToppingRouter(s.data, s.taoLogger).Route(r) + r.NotFound(func(w http.ResponseWriter, r *http.Request) { w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusNotFound)