httptool

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeStructureURL

func MakeStructureURL(uri string, params interface{}) string

MakeStructureURL builds a URL by using the structured params as the query string of the url. e.g. MakeStructureURL("https://example.com/", &testParams{State: "test", UserName: "hello"}) returns "https://example.com/?state=test&user_name=hello"

func MakeTemplateURL

func MakeTemplateURL(uri string, params map[string]string) string

MakeTemplateURL builds a URL by replacing the placeholders in the uri with the values in the params. e.g. MakeTemplateURL("https://example.com/:id", map[string]string{"id": "123"}) returns "https://example.com/123"

func MakeURL

func MakeURL(uri string, params url.Values) string

MakeURL builds a URL for the specified url string and params

func Request

func Request(ctx context.Context, opts *RequestOptions, data interface{}) error

Request represents a request to a service endpoint

Types

type Header struct {
	Key   string
	Value string
}

Header represents the HTTP header

type RequestOptions

type RequestOptions struct {
	// URI specifies the request's URI
	URI string

	// Method is the HTTP method
	Method string

	// ContentType is the HTTP content type
	ContentType string

	// JSONBody is the JSON body of the request
	JSONBody interface{}

	// Headers is the HTTP headers
	Headers []Header

	// Timeout is the HTTP timeout in seconds
	Timeout time.Duration
}

RequestOptions represents the HTTP request options

Jump to

Keyboard shortcuts

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