http

package
v0.4.10 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 5 Imported by: 10

Documentation

Overview

methods in this package automatically include a context with a timeout, in order to solve the problem of hanging requests and to avoid goroutine leaks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(url string, body []byte, timeout time.Duration) (*http.Response, error)

default header "Content-Type: application/json" is included.

func Do

func Do(requestFunc func(ctx context.Context) (*http.Request, error), timeout time.Duration) (*http.Response, error)

func Get

func Get(url string, timeout time.Duration) (*http.Response, error)

func GetWithHeader added in v0.4.0

func GetWithHeader(url string, timeout time.Duration, header map[string]string) (*http.Response, error)

func Post

func Post(url string, body []byte, timeout time.Duration) (*http.Response, error)

default header "Content-Type: application/json" is included.

func PostWithHeader added in v0.4.0

func PostWithHeader(url string, body []byte, timeout time.Duration, header map[string]string) (*http.Response, error)

default header "Content-Type: application/json" is included.

func Put

func Put(url string, body []byte, timeout time.Duration) (*http.Response, error)

default header "Content-Type: application/json" is included.

func PutByReader added in v0.4.8

func PutByReader(url string, body []byte, timeout time.Duration) (*http.Response, error)

Types

type HandlerMultiplexer

type HandlerMultiplexer struct {
	HandlerMap map[string]http.Handler
}

func (*HandlerMultiplexer) ServeHTTP

func (h *HandlerMultiplexer) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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