mirror of
https://gitea.com/gitea/act_runner.git
synced 2024-12-28 11:58:20 +01:00
d359276fe1
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
37 lines
748 B
Go
37 lines
748 B
Go
package client
|
|
|
|
import "github.com/bufbuild/connect-go"
|
|
|
|
// An Option configures a mutex.
|
|
type Option interface {
|
|
Apply(*HTTPClient)
|
|
}
|
|
|
|
// OptionFunc is a function that configure a value.
|
|
type OptionFunc func(*HTTPClient)
|
|
|
|
// Apply calls f(option)
|
|
func (f OptionFunc) Apply(cli *HTTPClient) {
|
|
f(cli)
|
|
}
|
|
|
|
// WithGRPC configures clients to use the HTTP/2 gRPC protocol.
|
|
func WithGRPC(c bool) Option {
|
|
return OptionFunc(func(cli *HTTPClient) {
|
|
if !c {
|
|
return
|
|
}
|
|
cli.opts = append(cli.opts, connect.WithGRPC())
|
|
})
|
|
}
|
|
|
|
// WithGRPCWeb configures clients to use the gRPC-Web protocol.
|
|
func WithGRPCWeb(c bool) Option {
|
|
return OptionFunc(func(cli *HTTPClient) {
|
|
if !c {
|
|
return
|
|
}
|
|
cli.opts = append(cli.opts, connect.WithGRPCWeb())
|
|
})
|
|
}
|