mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-22 19:19:42 +01:00
allow clients to set authority header (#68)
This commit is contained in:
parent
991b389a16
commit
24bdacca3a
1 changed files with 8 additions and 3 deletions
|
@ -18,6 +18,7 @@ import Control.Monad.IO.Class
|
|||
import Control.Monad.Trans.Except
|
||||
import qualified Data.ByteString as B
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.Maybe
|
||||
import Network.GRPC.LowLevel.Call
|
||||
import Network.GRPC.LowLevel.CompletionQueue
|
||||
import Network.GRPC.LowLevel.GRPC
|
||||
|
@ -61,11 +62,15 @@ data ClientConfig = ClientConfig {clientServerHost :: Host,
|
|||
-- channel on the client. Supplying an empty
|
||||
-- list will cause the channel to use gRPC's
|
||||
-- default options.
|
||||
clientSSLConfig :: Maybe ClientSSLConfig
|
||||
clientSSLConfig :: Maybe ClientSSLConfig,
|
||||
-- ^ If 'Nothing', the client will use an
|
||||
-- insecure connection to the server.
|
||||
-- Otherwise, will use the supplied config to
|
||||
-- connect using SSL.
|
||||
clientAuthority :: Maybe ByteString
|
||||
-- ^ If 'Nothing', the :authority pseudo-header will
|
||||
-- be the endpoint host. Otherwise, the :authority
|
||||
-- pseudo-header will be set to the supplied value.
|
||||
}
|
||||
|
||||
clientEndpoint :: ClientConfig -> Endpoint
|
||||
|
@ -132,10 +137,10 @@ clientRegisterMethod :: Client
|
|||
-> MethodName
|
||||
-> IO (C.CallHandle)
|
||||
clientRegisterMethod Client{..} meth = do
|
||||
let e = clientEndpoint clientConfig
|
||||
let host = fromMaybe (unEndpoint (clientEndpoint clientConfig)) (clientAuthority clientConfig)
|
||||
C.grpcChannelRegisterCall clientChannel
|
||||
(unMethodName meth)
|
||||
(unEndpoint e)
|
||||
host
|
||||
C.reserved
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue