Documentation ¶
Overview ¶
This package provides out-of-box configuration for initializing client object to calling of RESTful API services.
Configuration ¶
The "RestfulClientConfig" object defines various properties used to construct calling of OWL service.
Gentleman Client ¶
You could use "ApiService.NewClient()" to get "*gentleman.Client" object.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiService ¶
type ApiService struct {
// contains filtered or unexported fields
}
Provides general operation(as service) to RESTful API service
Example (NewClient) ¶
Constructs a client object by set-up configuration.
package main import ( "github.com/Cepave/open-falcon-backend/common/http" "github.com/Cepave/open-falcon-backend/common/http/client" ) func main() { httpClientConfig := client.NewDefaultConfig() httpClientConfig.Url = "http://some-1.mock.server/" restfulConfig := &http.RestfulClientConfig{ HttpClientConfig: httpClientConfig, FromModule: "query", } apiService := http.NewApiService(restfulConfig) client := apiService.NewClient() // The returned request is omitted in the example. _ = client.Get() // ... }
Output:
func NewApiService ¶
func NewApiService(config *RestfulClientConfig) *ApiService
Constructs a new service to API.
func (*ApiService) NewClient ¶
func (s *ApiService) NewClient() *gt.Client
Constructs a new client object with defined configuration(by RestfulClientConfig)
type RestfulClientConfig ¶
type RestfulClientConfig struct { // Configuration is used to set-up properties of supported library of HTTP client. *client.HttpClientConfig // If this value is non-empty, this service would add header "From-Module: <FromModule>" in HTTP request. FromModule string // The "NewClient()" function would USE the "Plugins" to construct "*gentleman.Client" object. Plugins []plugin.Plugin }
General configuration to MySqlApi
Click to show internal directories.
Click to hide internal directories.