diff --git a/handlers.go b/handlers.go index e35872a..71ada93 100644 --- a/handlers.go +++ b/handlers.go @@ -59,6 +59,7 @@ func createStatusHandler(c *echo.Context) *echo.HTTPError { } params.URL = strings.TrimSpace(params.URL) + params.Email = strings.TrimSpace(params.Email) if 0 == len(strings.TrimSpace(params.URL)) { return c.JSON(http.StatusBadRequest, "URL parameter required") @@ -72,6 +73,14 @@ func createStatusHandler(c *echo.Context) *echo.HTTPError { return handleError(http.StatusInternalServerError, "Problem saving your new site", err) } + // See NOTE above about ignoring the bool return value here as well + if len(params.Email) > 0 { + _, err = redisClient.Hset(redisScopedKey(emailsRedisKey), params.URL, []byte(params.Email)) + if err != nil { + return handleError(http.StatusInternalServerError, "Problem saving your site email address to alert", err) + } + } + return c.JSON(http.StatusCreated, &Site{URL: params.URL}) } diff --git a/main.go b/main.go index 354d476..d4d7a67 100644 --- a/main.go +++ b/main.go @@ -12,7 +12,8 @@ import ( ) const ( - sitesRedisKey = "sites" + sitesRedisKey = "sites" + emailsRedisKey = "site-emails" ) var (