This tiny API provides subscribing and unsubscribing of users using the go-news package.
Accepts a form body with a newsletter
name and subscriber and email
.
Requires the newsletter
and token
query-string parameters. The token must be signed with the TOKEN_SECRET and the included token package, this ensures that only people who received an email with this token in their unsubscribe link can perform an unsubscribe.
- Create a DynamoDB table with a Partition Key of "newsletter", and a Sort Key of "email".
- Deploy this app however you prefer, you could use Up for example
- Define the required environment variables:
- TOKEN_SECRET: The secret used for signing unsubscribe tokens
- SUBSCRIBE_REDIRECT_URL: The redirect URL used for a successful subscription (thank you page)
- UNSUBSCRIBE_REDIRECT_URL: The redirect URL used for a successful unsubscribe (bye bye page)
- DYNAMO_TABLE: An optional table name, defaults to "news"