removed default Apigee Client ID and added placeholder
This commit is contained in:
parent
a72c0c729a
commit
c1710a53c1
2 changed files with 60 additions and 69 deletions
|
@ -75,6 +75,7 @@ func (fe *frontendServer) homeHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
"session_id": sessionID(r),
|
"session_id": sessionID(r),
|
||||||
"request_id": r.Context().Value(ctxKeyRequestID{}),
|
"request_id": r.Context().Value(ctxKeyRequestID{}),
|
||||||
"apigee_client_id": currentApigeeClientID(r),
|
"apigee_client_id": currentApigeeClientID(r),
|
||||||
|
"apigee_client_id_placeholder": ApigeeClientIDPlaceholder,
|
||||||
"user_currency": currentCurrency(r),
|
"user_currency": currentCurrency(r),
|
||||||
"currencies": currencies,
|
"currencies": currencies,
|
||||||
"products": ps,
|
"products": ps,
|
||||||
|
@ -134,6 +135,7 @@ func (fe *frontendServer) productHandler(w http.ResponseWriter, r *http.Request)
|
||||||
"session_id": sessionID(r),
|
"session_id": sessionID(r),
|
||||||
"request_id": r.Context().Value(ctxKeyRequestID{}),
|
"request_id": r.Context().Value(ctxKeyRequestID{}),
|
||||||
"apigee_client_id": currentApigeeClientID(r),
|
"apigee_client_id": currentApigeeClientID(r),
|
||||||
|
"apigee_client_id_placeholder": ApigeeClientIDPlaceholder,
|
||||||
"ad": fe.chooseAd(r.Context(), p.Categories, log),
|
"ad": fe.chooseAd(r.Context(), p.Categories, log),
|
||||||
"user_currency": currentCurrency(r),
|
"user_currency": currentCurrency(r),
|
||||||
"currencies": currencies,
|
"currencies": currencies,
|
||||||
|
@ -240,6 +242,7 @@ func (fe *frontendServer) viewCartHandler(w http.ResponseWriter, r *http.Request
|
||||||
"session_id": sessionID(r),
|
"session_id": sessionID(r),
|
||||||
"request_id": r.Context().Value(ctxKeyRequestID{}),
|
"request_id": r.Context().Value(ctxKeyRequestID{}),
|
||||||
"apigee_client_id": currentApigeeClientID(r),
|
"apigee_client_id": currentApigeeClientID(r),
|
||||||
|
"apigee_client_id_placeholder": ApigeeClientIDPlaceholder,
|
||||||
"user_currency": currentCurrency(r),
|
"user_currency": currentCurrency(r),
|
||||||
"currencies": currencies,
|
"currencies": currencies,
|
||||||
"recommendations": recommendations,
|
"recommendations": recommendations,
|
||||||
|
@ -305,6 +308,7 @@ func (fe *frontendServer) placeOrderHandler(w http.ResponseWriter, r *http.Reque
|
||||||
"session_id": sessionID(r),
|
"session_id": sessionID(r),
|
||||||
"request_id": r.Context().Value(ctxKeyRequestID{}),
|
"request_id": r.Context().Value(ctxKeyRequestID{}),
|
||||||
"apigee_client_id": currentApigeeClientID(r),
|
"apigee_client_id": currentApigeeClientID(r),
|
||||||
|
"apigee_client_id_placeholder": ApigeeClientIDPlaceholder,
|
||||||
"user_currency": currentCurrency(r),
|
"user_currency": currentCurrency(r),
|
||||||
"order": order.GetOrder(),
|
"order": order.GetOrder(),
|
||||||
"total_paid": &totalPaid,
|
"total_paid": &totalPaid,
|
||||||
|
@ -354,27 +358,13 @@ func (fe *frontendServer) viewConfigHandler(w http.ResponseWriter, r *http.Reque
|
||||||
log := r.Context().Value(ctxKeyLog{}).(logrus.FieldLogger)
|
log := r.Context().Value(ctxKeyLog{}).(logrus.FieldLogger)
|
||||||
log.Debug("Viewing the configuration")
|
log.Debug("Viewing the configuration")
|
||||||
|
|
||||||
currencies, err := fe.getCurrencies(r.Context())
|
|
||||||
if err != nil {
|
|
||||||
renderHTTPError(log, r, w, errors.Wrap(err, "could not retrieve currencies"), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
cart, err := fe.getCart(r.Context(), sessionID(r))
|
|
||||||
if err != nil {
|
|
||||||
renderHTTPError(log, r, w, errors.Wrap(err, "could not retrieve cart"), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
apigeeClientID := currentApigeeClientID(r)
|
apigeeClientID := currentApigeeClientID(r)
|
||||||
|
|
||||||
if err := templates.ExecuteTemplate(w, "config", map[string]interface{}{
|
if err := templates.ExecuteTemplate(w, "config", map[string]interface{}{
|
||||||
"session_id": sessionID(r),
|
"session_id": sessionID(r),
|
||||||
"request_id": r.Context().Value(ctxKeyRequestID{}),
|
"request_id": r.Context().Value(ctxKeyRequestID{}),
|
||||||
"apigee_client_id": apigeeClientID,
|
"apigee_client_id": apigeeClientID,
|
||||||
"user_currency": currentCurrency(r),
|
"apigee_client_id_placeholder": ApigeeClientIDPlaceholder,
|
||||||
"currencies": currencies,
|
|
||||||
"cart_size": len(cart),
|
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
|
@ -423,6 +413,7 @@ func renderHTTPError(log logrus.FieldLogger, r *http.Request, w http.ResponseWri
|
||||||
"session_id": sessionID(r),
|
"session_id": sessionID(r),
|
||||||
"request_id": r.Context().Value(ctxKeyRequestID{}),
|
"request_id": r.Context().Value(ctxKeyRequestID{}),
|
||||||
"apigee_client_id": currentApigeeClientID(r),
|
"apigee_client_id": currentApigeeClientID(r),
|
||||||
|
"apigee_client_id_placeholder": ApigeeClientIDPlaceholder,
|
||||||
"error": errMsg,
|
"error": errMsg,
|
||||||
"status_code": code,
|
"status_code": code,
|
||||||
"status": http.StatusText(code)})
|
"status": http.StatusText(code)})
|
||||||
|
@ -441,7 +432,7 @@ func currentApigeeClientID(r *http.Request) string {
|
||||||
if c != nil {
|
if c != nil {
|
||||||
return c.Value
|
return c.Value
|
||||||
}
|
}
|
||||||
return defaultApigeeClientID
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func sessionID(r *http.Request) string {
|
func sessionID(r *http.Request) string {
|
||||||
|
|
|
@ -38,12 +38,12 @@ const (
|
||||||
port = "8080"
|
port = "8080"
|
||||||
defaultCurrency = "USD"
|
defaultCurrency = "USD"
|
||||||
cookieMaxAge = 60 * 60 * 48
|
cookieMaxAge = 60 * 60 * 48
|
||||||
defaultApigeeClientID = "Add your Apigee Application Client ID here"
|
|
||||||
|
|
||||||
cookiePrefix = "shop_"
|
cookiePrefix = "shop_"
|
||||||
cookieSessionID = cookiePrefix + "session-id"
|
cookieSessionID = cookiePrefix + "session-id"
|
||||||
cookieCurrency = cookiePrefix + "currency"
|
cookieCurrency = cookiePrefix + "currency"
|
||||||
apigeeClientIDHeaderName = "x-api-key"
|
apigeeClientIDHeaderName = "x-api-key"
|
||||||
|
ApigeeClientIDPlaceholder = "Add your Apigee Application Client ID here"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue