Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Nov 7, 2024
1 parent 57482fb commit 0aba5c2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,26 @@ func logLevelForError(err error) log.Level {
}
return log.Warn
}

type hostOption struct {
host string
}

func (h hostOption) WrapUnary(unaryFunc connect.UnaryFunc) connect.UnaryFunc {
return func(ctx context.Context, request connect.AnyRequest) (connect.AnyResponse, error) {
request.Header().Set("Host", h.host)
return unaryFunc(ctx, request)
}
}

func (h hostOption) WrapStreamingClient(clientFunc connect.StreamingClientFunc) connect.StreamingClientFunc {
return clientFunc
}

func (h hostOption) WrapStreamingHandler(handlerFunc connect.StreamingHandlerFunc) connect.StreamingHandlerFunc {
return handlerFunc
}

func setHost(host string) connect.ClientOption {
return connect.WithInterceptors(hostOption{host: host})
}

0 comments on commit 0aba5c2

Please sign in to comment.