bricks icon indicating copy to clipboard operation
bricks copied to clipboard

Locale: Either do not add to context if empty or return false if requested and is empty

Open daemonfire300 opened this issue 4 years ago • 0 comments

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

daemonfire300 avatar Jun 22 '21 09:06 daemonfire300