mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-26 21:19:43 +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 Control.Monad.Trans.Except
|
||||||
import qualified Data.ByteString as B
|
import qualified Data.ByteString as B
|
||||||
import Data.ByteString (ByteString)
|
import Data.ByteString (ByteString)
|
||||||
|
import Data.Maybe
|
||||||
import Network.GRPC.LowLevel.Call
|
import Network.GRPC.LowLevel.Call
|
||||||
import Network.GRPC.LowLevel.CompletionQueue
|
import Network.GRPC.LowLevel.CompletionQueue
|
||||||
import Network.GRPC.LowLevel.GRPC
|
import Network.GRPC.LowLevel.GRPC
|
||||||
|
@ -61,11 +62,15 @@ data ClientConfig = ClientConfig {clientServerHost :: Host,
|
||||||
-- channel on the client. Supplying an empty
|
-- channel on the client. Supplying an empty
|
||||||
-- list will cause the channel to use gRPC's
|
-- list will cause the channel to use gRPC's
|
||||||
-- default options.
|
-- default options.
|
||||||
clientSSLConfig :: Maybe ClientSSLConfig
|
clientSSLConfig :: Maybe ClientSSLConfig,
|
||||||
-- ^ If 'Nothing', the client will use an
|
-- ^ If 'Nothing', the client will use an
|
||||||
-- insecure connection to the server.
|
-- insecure connection to the server.
|
||||||
-- Otherwise, will use the supplied config to
|
-- Otherwise, will use the supplied config to
|
||||||
-- connect using SSL.
|
-- 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
|
clientEndpoint :: ClientConfig -> Endpoint
|
||||||
|
@ -132,10 +137,10 @@ clientRegisterMethod :: Client
|
||||||
-> MethodName
|
-> MethodName
|
||||||
-> IO (C.CallHandle)
|
-> IO (C.CallHandle)
|
||||||
clientRegisterMethod Client{..} meth = do
|
clientRegisterMethod Client{..} meth = do
|
||||||
let e = clientEndpoint clientConfig
|
let host = fromMaybe (unEndpoint (clientEndpoint clientConfig)) (clientAuthority clientConfig)
|
||||||
C.grpcChannelRegisterCall clientChannel
|
C.grpcChannelRegisterCall clientChannel
|
||||||
(unMethodName meth)
|
(unMethodName meth)
|
||||||
(unEndpoint e)
|
host
|
||||||
C.reserved
|
C.reserved
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue