http

package
v0.1.3-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents an http client It uses the native client from net/http package

func NewClient

func NewClient(timeout uint) *Client

NewClient returns a new http client with the specified timeout in milliseconds

func (*Client) Do

func (hc *Client) Do(request *Request) (*Response, error)

Do sends an http request and returns an http resposne

type Request

type Request struct {
	// URL specifies URL to access.
	Url string
	// Method specifies the http method (GET, POST, PUT, etd.)
	// An empty string means GET
	Method string
	// Body is the  request body to be send with the request.
	// A nil body means the request has no body.
	Body []byte
	// Headers contains the headers to be sent with the request
	Headers map[string][]string
	// QueryParams specifies the query parameters to be added in the request URL
	QueryParams map[string][]string
}

Request represents a http request.

type Response

type Response struct {
	Status     string              // specifies the status of the response
	StatusCode uint                // specifies the http status code of response
	Headers    map[string][]string // headers set in the response
	Body       []byte              // the response body
}

Response represents the response from an http request

Jump to

Keyboard shortcuts

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