http

package
v0.0.0-...-5416f79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2017 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL