httphelper

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 5 Imported by: 5

README

httphelper

Go Reference

Helpers for Go's net/http package.

Documentation

Overview

Package httphelper contains net/http package helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthBasic added in v0.6.0

func AuthBasic(userid, password string) string

AuthBasic returns Basic authorization value.

func ErrorOptionWithObject added in v0.5.0

func ErrorOptionWithObject() func(o *ErrorOptions)

ErrorOptionWithObject turns on Error's Object JSON deserialization from HTTP response body.

Types

type Error added in v0.5.0

type Error[E any] struct {
	StatusCode int    `json:"status_code"`
	Status     string `json:"status"`
	Object     E      `json:"object,omitempty"`
}

Error represents a HTTP error. Object (if turned on in options) is deserialized from JSON read from HTTP response body (if any).

func NewError added in v0.5.0

func NewError[E any](rs *http.Response, opts ...func(o *ErrorOptions)) (*Error[E], error)

NewError creates Error from http.Response.

func (*Error[B]) Error added in v0.5.0

func (e *Error[B]) Error() string

Error implements the [error] interface.

type ErrorOptions added in v0.5.0

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

ErrorOptions contains Error options.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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