bricks
bricks copied to clipboard
Locale: Either do not add to context if empty or return false if requested and is empty
Problem
The locale package adds locale to the context if used as middleware in http. If a caller later retrieves information from the context it happily returns a locale and true.
This might be confusing because (a) this happens when the header is not set (b) returning an empty string and true is not a happy path in my opinion.
https://github.com/pace/bricks/blob/378d8c0c9298aa9143933abf257a96edda5691ec/locale/http.go#L15
https://github.com/pace/bricks/blob/378d8c0c9298aa9143933abf257a96edda5691ec/locale/context.go#L26