Config.go raw

   1  // Copyright 2018-2025 JDCLOUD.COM
   2  //
   3  // Licensed under the Apache License, Version 2.0 (the "License");
   4  // you may not use this file except in compliance with the License.
   5  // You may obtain a copy of the License at
   6  //
   7  //     http://www.apache.org/licenses/LICENSE-2.0
   8  //
   9  // Unless required by applicable law or agreed to in writing, software
  10  // distributed under the License is distributed on an "AS IS" BASIS,
  11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12  // See the License for the specific language governing permissions and
  13  // limitations under the License.
  14  
  15  package core
  16  
  17  import "time"
  18  
  19  type Config struct {
  20  	Scheme   string
  21  	Endpoint string
  22  	Timeout  time.Duration
  23  }
  24  
  25  // NewConfig returns a pointer of Config
  26  //
  27  // scheme only accepts http or https
  28  //
  29  // endpoint is the host to access, the connection could not be created if it's error
  30  func NewConfig() *Config {
  31  	return &Config{SchemeHttps, "www.jdcloud-api.com", 10 * time.Second}
  32  }
  33  
  34  func (c *Config) SetScheme(scheme string) {
  35  	c.Scheme = scheme
  36  }
  37  
  38  func (c *Config) SetEndpoint(endpoint string) {
  39  	c.Endpoint = endpoint
  40  }
  41  
  42  func (c *Config) SetTimeout(timeout time.Duration) {
  43  	c.Timeout = timeout
  44  }
  45