Skip to content

Commit

Permalink
replace user agent with custom version header
Browse files Browse the repository at this point in the history
  • Loading branch information
wass3r committed Aug 2, 2024
1 parent d2b16aa commit d724e0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
12 changes: 6 additions & 6 deletions src/elm/Api/Api.elm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Api.Api exposing
)

import Api.Endpoint as Endpoint exposing (Endpoint)
import Api.Header exposing (userAgent, userAgentString)
import Api.Header exposing (velaVersionHeader)
import Api.Pagination as Pagination
import Auth.Session exposing (Session(..))
import Http
Expand Down Expand Up @@ -216,7 +216,7 @@ get : String -> Endpoint -> Decoder b -> Request b
get api endpoint decoder =
request
{ method = "GET"
, headers = [ userAgent userAgentString ]
, headers = [ velaVersionHeader ]
, url = Endpoint.toUrl api endpoint
, body = Http.emptyBody
, decoder = decoder
Expand All @@ -229,7 +229,7 @@ post : String -> Endpoint -> Http.Body -> Decoder b -> Request b
post api endpoint body decoder =
request
{ method = "POST"
, headers = [ userAgent userAgentString ]
, headers = [ velaVersionHeader ]
, url = Endpoint.toUrl api endpoint
, body = body
, decoder = decoder
Expand All @@ -242,7 +242,7 @@ put : String -> Endpoint -> Http.Body -> Decoder b -> Request b
put api endpoint body decoder =
request
{ method = "PUT"
, headers = [ userAgent userAgentString ]
, headers = [ velaVersionHeader ]
, url = Endpoint.toUrl api endpoint
, body = body
, decoder = decoder
Expand All @@ -255,7 +255,7 @@ delete : String -> Endpoint -> Decoder b -> Request b
delete api endpoint decoder =
request
{ method = "DELETE"
, headers = [ userAgent userAgentString ]
, headers = [ velaVersionHeader ]
, url = Endpoint.toUrl api endpoint
, body = Http.emptyBody
, decoder = decoder
Expand All @@ -268,7 +268,7 @@ patch : String -> Endpoint -> Decoder b -> Request b
patch api endpoint decoder =
request
{ method = "PATCH"
, headers = [ userAgent userAgentString ]
, headers = [ velaVersionHeader ]
, url = Endpoint.toUrl api endpoint
, body = Http.emptyBody
, decoder = decoder
Expand Down
19 changes: 6 additions & 13 deletions src/elm/Api/Header.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SPDX-License-Identifier: Apache-2.0
--}


module Api.Header exposing (get, userAgent, userAgentString)
module Api.Header exposing (get, velaVersionHeader)

import Dict exposing (Dict)
import Http
Expand All @@ -28,18 +28,11 @@ get key headers =
Dict.get key_ headers_


{-| userAgentString is the default User-Agent header value for the UI.
{-| velaVersionHeader creates a User-Agent header with the specified value.
TODO: pass this in via flags/config.
TODO: allow this to be controlled via flags/config
-}
userAgentString : String
userAgentString =
"vela/ui"


{-| userAgent creates a User-Agent header with the specified value.
-}
userAgent : String -> Http.Header
userAgent value =
Http.header "user-agent" value
velaVersionHeader : Http.Header
velaVersionHeader =
Http.header "x-vela-ui-version" "vela/ui"

0 comments on commit d724e0f

Please sign in to comment.