removed default Apigee Client ID and added placeholder

This commit is contained in:
phriscage 2018-12-04 14:02:34 -08:00
parent a72c0c729a
commit c1710a53c1
2 changed files with 60 additions and 69 deletions

View file

@ -75,6 +75,7 @@ func (fe *frontendServer) homeHandler(w http.ResponseWriter, r *http.Request) {
"session_id": sessionID(r),
"request_id": r.Context().Value(ctxKeyRequestID{}),
"apigee_client_id": currentApigeeClientID(r),
"apigee_client_id_placeholder": ApigeeClientIDPlaceholder,
"user_currency": currentCurrency(r),
"currencies": currencies,
"products": ps,
@ -134,6 +135,7 @@ func (fe *frontendServer) productHandler(w http.ResponseWriter, r *http.Request)
"session_id": sessionID(r),
"request_id": r.Context().Value(ctxKeyRequestID{}),
"apigee_client_id": currentApigeeClientID(r),
"apigee_client_id_placeholder": ApigeeClientIDPlaceholder,
"ad": fe.chooseAd(r.Context(), p.Categories, log),
"user_currency": currentCurrency(r),
"currencies": currencies,
@ -240,6 +242,7 @@ func (fe *frontendServer) viewCartHandler(w http.ResponseWriter, r *http.Request
"session_id": sessionID(r),
"request_id": r.Context().Value(ctxKeyRequestID{}),
"apigee_client_id": currentApigeeClientID(r),
"apigee_client_id_placeholder": ApigeeClientIDPlaceholder,
"user_currency": currentCurrency(r),
"currencies": currencies,
"recommendations": recommendations,
@ -305,6 +308,7 @@ func (fe *frontendServer) placeOrderHandler(w http.ResponseWriter, r *http.Reque
"session_id": sessionID(r),
"request_id": r.Context().Value(ctxKeyRequestID{}),
"apigee_client_id": currentApigeeClientID(r),
"apigee_client_id_placeholder": ApigeeClientIDPlaceholder,
"user_currency": currentCurrency(r),
"order": order.GetOrder(),
"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.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)
if err := templates.ExecuteTemplate(w, "config", map[string]interface{}{
"session_id": sessionID(r),
"request_id": r.Context().Value(ctxKeyRequestID{}),
"apigee_client_id": apigeeClientID,
"user_currency": currentCurrency(r),
"currencies": currencies,
"cart_size": len(cart),
"apigee_client_id_placeholder": ApigeeClientIDPlaceholder,
}); err != nil {
log.Println(err)
}
@ -423,6 +413,7 @@ func renderHTTPError(log logrus.FieldLogger, r *http.Request, w http.ResponseWri
"session_id": sessionID(r),
"request_id": r.Context().Value(ctxKeyRequestID{}),
"apigee_client_id": currentApigeeClientID(r),
"apigee_client_id_placeholder": ApigeeClientIDPlaceholder,
"error": errMsg,
"status_code": code,
"status": http.StatusText(code)})
@ -441,7 +432,7 @@ func currentApigeeClientID(r *http.Request) string {
if c != nil {
return c.Value
}
return defaultApigeeClientID
return ""
}
func sessionID(r *http.Request) string {

View file

@ -38,12 +38,12 @@ const (
port = "8080"
defaultCurrency = "USD"
cookieMaxAge = 60 * 60 * 48
defaultApigeeClientID = "Add your Apigee Application Client ID here"
cookiePrefix = "shop_"
cookieSessionID = cookiePrefix + "session-id"
cookieCurrency = cookiePrefix + "currency"
apigeeClientIDHeaderName = "x-api-key"
ApigeeClientIDPlaceholder = "Add your Apigee Application Client ID here"
)
var (