utils

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRedirect

func CheckRedirect(req *http.Request, via []*http.Request) error

func CleanOutAllSlashes

func CleanOutAllSlashes(t string) string

func CreateDefaultHttpClient added in v0.6.3

func CreateDefaultHttpClient() *http.Client

func CreateError

func CreateError(w io.Writer, err error, message string, code int) error

func DoRequest

func DoRequest(
	ctx context.Context,
	client sabuhp.HttpClient,
	method string,
	route string,
	body io.Reader,
	headers http.Header,
) (*http.Request, *http.Response, error)

DoRequest makes a request for giving parameters.

func GetFileMimeType

func GetFileMimeType(path string) string

GetFileMimeType returns associated mime type for giving file extension.

func LetsEncryptTLS

func LetsEncryptTLS(http2 bool) (*autocert.Manager, *tls.Config)

LetsEncryptTLS returns a tls.Config instance which retrieves its its tls certificate from LetsEncrypt service.

func LoadTLS

func LoadTLS(cert, key string) (*tls.Config, error)

LoadTLS loads a tls.Config from a key and cert file path

func ParseAuthorization

func ParseAuthorization(val string) (authType string, token string, err error)

ParseAuthorization returns the scheme and token of the Authorization string if it's valid.

func ParseTokens

func ParseTokens(val string) ([]string, error)

ParseTokens parses the base64 encoded token sent as part of the Authorization string, It expects all parts of string to be separated with ':', returning split slice.

func ReduceMultipleSlashTo

func ReduceMultipleSlashTo(t string, replace string) string

func ReduceMultipleSlashToOne

func ReduceMultipleSlashToOne(t string) string

Types

type CloseErrorChannel

type CloseErrorChannel struct {
	T     string
	G     string
	Error error
}

func (*CloseErrorChannel) Close

func (es *CloseErrorChannel) Close()

func (*CloseErrorChannel) Err

func (es *CloseErrorChannel) Err() error

func (*CloseErrorChannel) Group

func (es *CloseErrorChannel) Group() string

func (*CloseErrorChannel) Topic

func (es *CloseErrorChannel) Topic() string

type ErrorHandler

type ErrorHandler struct {
	Err error
}

func (*ErrorHandler) Run

func (es *ErrorHandler) Run() error

type NormalisedReader

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

NormalisedReader reader which normalises line endings "/r" and "/r/n" are converted to "/n"

func NewNormalisedReader

func NewNormalisedReader(r io.Reader) *NormalisedReader

func (*NormalisedReader) Read

func (norm *NormalisedReader) Read(p []byte) (n int, err error)

type RequestErr

type RequestErr struct {
	Code    int
	Message string
}

func (*RequestErr) Error

func (r *RequestErr) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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