| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package gateway
- import "git.sxidc.com/go-tools/utils/http_client"
- type Gateway struct {
- httpClient *http_client.Client
- options *Options
- }
- func NewGateway(opts ...Option) *Gateway {
- options := new(Options)
- for _, opt := range opts {
- opt(options)
- }
- if options.timeoutSec == 0 {
- options.timeoutSec = 30
- }
- return &Gateway{
- httpClient: http_client.New(),
- options: options,
- }
- }
- func DestroyGateway(gateway *Gateway) {
- if gateway == nil {
- return
- }
- http_client.Destroy(gateway.httpClient)
- gateway.httpClient = nil
- gateway = nil
- }
- type Option func(options *Options)
- type Options struct {
- timeoutSec int64
- }
- func WithTimeoutSec(timeoutSec int64) Option {
- return func(options *Options) {
- options.timeoutSec = timeoutSec
- }
- }
|