mini

package module
v0.1.1-0...-84574a3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 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.

README

mini

mini

Release

A tiny, dependency-free HTTP client for Go.

mini exposes a straightforward request/response API with no third-party dependencies. It keeps memory use small, so it is comfortable in embedded runtimes, and it can be vendored directly into any project.

Installation

go get github.com/coccinella-labs/mini@latest

Usage

import "github.com/coccinella-labs/mini"

resp, err := mini.Get("https://example.com/health")
if err != nil {
    panic(err)
}
fmt.Printf("%d %s\n", resp.StatusCode, resp.Body)

With a client:

client := mini.New(
    mini.WithTimeout(5 * time.Second),
    mini.WithHeader("Authorization", "Bearer token"),
)
resp, err := client.Post("https://example.com/api", []byte(`{"a":1}`))

Development

go vet ./...
go test ./...
gofmt -l .

License

MIT

Documentation

Overview

Package mini is a tiny, dependency-free HTTP client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Timeout time.Duration
	Headers map[string]string
}

Client issues HTTP requests with a default timeout and shared headers.

func New

func New(opts ...Option) *Client

New returns a Client with sensible defaults, tuned by opts.

func (*Client) Do

func (c *Client) Do(method, url string, body []byte) (*Response, error)

Do sends a request with the given method, URL, and optional body.

func (*Client) Get

func (c *Client) Get(url string) (*Response, error)

Get performs a GET request.

func (*Client) Post

func (c *Client) Post(url string, body []byte) (*Response, error)

Post performs a POST request with the given body.

type Option

type Option func(*Client)

Option configures a Client.

func WithHeader

func WithHeader(key, value string) Option

WithHeader sets a default header on every request.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the per-request timeout.

type Response

type Response struct {
	StatusCode int
	Header     http.Header
	Body       []byte
}

Response wraps the parts of an HTTP response callers usually need.

func Get

func Get(url string) (*Response, error)

Get performs a GET request with a default client.

func Post

func Post(url string, body []byte) (*Response, error)

Post performs a POST request with a default client.

Jump to

Keyboard shortcuts

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