Move stuff

This commit is contained in:
Richard Feldman
2018-08-05 04:13:33 -04:00
parent bf20622319
commit 7793c69762
3419 changed files with 6 additions and 7 deletions

View File

@@ -0,0 +1,31 @@
module Data.AuthToken exposing (AuthToken, decoder, encode, withAuthorization)
import HttpBuilder exposing (RequestBuilder, withHeader)
import Json.Decode as Decode exposing (Decoder)
import Json.Encode as Encode exposing (Value)
type AuthToken
= AuthToken String
encode : AuthToken -> Value
encode (AuthToken token) =
Encode.string token
decoder : Decoder AuthToken
decoder =
Decode.string
|> Decode.map AuthToken
withAuthorization : Maybe AuthToken -> RequestBuilder a -> RequestBuilder a
withAuthorization maybeToken builder =
case maybeToken of
Just (AuthToken token) ->
builder
|> withHeader "authorization" ("Token " ++ token)
Nothing ->
builder