diff --git a/internal/webserver/response_helpers.go b/internal/webserver/response_helpers.go index f790815..2c0b2a2 100644 --- a/internal/webserver/response_helpers.go +++ b/internal/webserver/response_helpers.go @@ -246,12 +246,16 @@ func cursor_to_query_params(c persistence.Cursor) string { return result.Encode() } +type key string + +const TWEET_KEY = key("tweet") + func add_tweet_to_context(ctx context.Context, tweet scraper.Tweet) context.Context { - return context.WithValue(ctx, "tweet", tweet) + return context.WithValue(ctx, TWEET_KEY, tweet) } func get_tweet_from_context(ctx context.Context) scraper.Tweet { - tweet, is_ok := ctx.Value("tweet").(scraper.Tweet) + tweet, is_ok := ctx.Value(TWEET_KEY).(scraper.Tweet) if !is_ok { panic("Tweet not found in context") }