[i18n] Add user language to the headers in all API requests
parent
3913712bbd
commit
da17a265bf
|
@ -22,16 +22,25 @@
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
class HttpService extends taiga.Service
|
class HttpService extends taiga.Service
|
||||||
@.$inject = ["$http", "$q", "$tgStorage"]
|
@.$inject = ["$http", "$q", "$tgStorage", "$rootScope"]
|
||||||
|
|
||||||
|
constructor: (@http, @q, @storage, @rootScope) ->
|
||||||
|
super()
|
||||||
|
|
||||||
headers: ->
|
headers: ->
|
||||||
|
headers = {}
|
||||||
|
|
||||||
|
# Authorization
|
||||||
token = @storage.get('token')
|
token = @storage.get('token')
|
||||||
if token
|
if token
|
||||||
return {"Authorization":"Bearer #{token}"}
|
headers["Authorization"] = "Bearer #{token}"
|
||||||
return {}
|
|
||||||
|
|
||||||
constructor: (@http, @q, @storage) ->
|
# Accept-Language
|
||||||
super()
|
lang = @rootScope.user?.lang
|
||||||
|
if lang
|
||||||
|
headers["Accept-Language"] = lang
|
||||||
|
|
||||||
|
return headers
|
||||||
|
|
||||||
request: (options) ->
|
request: (options) ->
|
||||||
options.headers = _.merge({}, options.headers or {}, @.headers())
|
options.headers = _.merge({}, options.headers or {}, @.headers())
|
||||||
|
|
Loading…
Reference in New Issue