httpx

package
v0.0.0-...-f250034 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package httpx provides helper functions for making HTTP requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(req *http.Request) (*http.Response, error)

Do sends an HTTP request and returns an HTTP response.

func MockServer

func MockServer() *httptest.Server

MockServer creates a mock HTTP server and installs its client instead of the default one. Serves responses from the file system instead of remote calls. Should be used for testing purposes only.

Types

type Client

type Client interface {
	Do(req *http.Request) (*http.Response, error)
}

Client is something that can send HTTP requests.

type MockClient

type MockClient struct {
	// contains filtered or unexported fields
}

MockClient serves responses from the file system instead of remote calls. Should be used for testing purposes only.

func Mock

func Mock(path ...string) *MockClient

Mock creates a new MockClient and installs it instead of the default one.

func (*MockClient) Do

func (c *MockClient) Do(req *http.Request) (*http.Response, error)

Do serves the file according to the request URL.

Jump to

Keyboard shortcuts

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