utils

package
v0.0.0-...-b44404f Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: CC-BY-4.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsDotDot

func ContainsDotDot(v string) bool

func ForceIPHTTPClient

func ForceIPHTTPClient(ip, port string) *http.Client

func ForceIPWebsocketDialer

func ForceIPWebsocketDialer(ip, port string) *websocket.Dialer

func IsMultipart

func IsMultipart(r *http.Request) bool

IsMultipart returns true if the given request is multipart forrm

func IsSlashRune

func IsSlashRune(r rune) bool

func JSONMarshal

func JSONMarshal(t interface{}) ([]byte, error)

JSONMarshal does not escape HTML

func MarshalJSONErr

func MarshalJSONErr(message, code string, args ...any) []byte

func Redirect2HTTPS

func Redirect2HTTPS(w http.ResponseWriter, req *http.Request)

func SendError

func SendError(w http.ResponseWriter, message, code string, statusCode int)

func SendErrorAndLog

func SendErrorAndLog(w http.ResponseWriter, message, code string, statusCode int, origin string, err error)

func SendInternalError

func SendInternalError(w http.ResponseWriter, origin string, err error)

func SendSuccess

func SendSuccess(w http.ResponseWriter, resp interface{})

func SplitHostPort

func SplitHostPort(hostport string) (string, string)

func SplitSlash

func SplitSlash(url string) []string

func StripPort

func StripPort(hostport string) string

StripPort also removes IPV6 addresses square brackets

func UniqueSecureID120

func UniqueSecureID120() (string, error)

func UniqueSecureID36

func UniqueSecureID36() (string, error)

func UniqueSecureID60

func UniqueSecureID60() (string, error)

func UploadEmbedFolderMultipart

func UploadEmbedFolderMultipart(client *http.Client, url, method string, relfilepaths []string, files []fs.File, fields ...string) (*http.Response, error)

func UploadFileMultipart

func UploadFileMultipart(client *http.Client, url string, path string) (*http.Response, error)

func UploadFolderMultipart

func UploadFolderMultipart(client *http.Client, url, method string, folder string, fields ...string) (*http.Response, error)

Types

type JSONErr

type JSONErr struct {
	Success bool   `json:"success"`
	Message string `json:"message,omitempty"`
	Code    string `json:"code,omitempty"`
}

func UnmarshalJSONErr

func UnmarshalJSONErr(b []byte) *JSONErr

Jump to

Keyboard shortcuts

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