generalutils

package
v0.0.0-...-8f1e39b Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewLineMatcherRegex = regexp.MustCompile(`\r?\n`)

NewLineMatcherRegex Regex to remove all new lines.

Functions

func ClientIP

func ClientIP(r *http.Request) string

ClientIP will return client ip from request.

func GetDocumentFromURL

func GetDocumentFromURL(rawURL string, opts ...GetDocumentFromURLOption) ([]byte, error)

GetDocumentFromURL retrieves a textual document from a URL, which may be an AWS ARN for an S3 object, Secrets Manager secret, or Systems Manager parameter (arn:...); an HTTP or HTTPS URL; an S3 URL in the form s3://bucket/key; or a file in URL or regular path form.

func GetRequestHost

func GetRequestHost(r *http.Request) string

func GetRequestScheme

func GetRequestScheme(r *http.Request) string

func GetRequestURI

func GetRequestURI(r *http.Request) string

func ParseCipherSuite

func ParseCipherSuite(suiteName string) uint16

ParseCipherSuite parses a cipher suite name into the tls package cipher suite id.

If the name is not recognized, 0 is returned.

func ParseTLSVersion

func ParseTLSVersion(tlsVersionString string) uint16

ParseTLSVersion parses the TLS version number from a string. This accepts raw version numbers "1.0", "1.1", "1.2", "1.3". If the string is prefixed with "TLS ", "TLSv", "TLS-", or "TLS_" (case-insensitive), that prefix is removed. The decimal separator ('.') can be replaced with either a '_' or a '-'.

For example: "TLSv1.2", "TLS_1-2", "tls-1_2", "TLs 1-2", etc., are equivalent and return tls.VersionTLS12.

If the version number cannot be parsed, 0 is returned.

func ValidateDocumentURL

func ValidateDocumentURL(rawURL string) error

ValidateDocumentURL verifies the document URL is supported.

If the URL is malformed, contains an unsupported scheme, or uses unsupported features (e.g. query arguments or fragments for AWS URLs), an error is returned.

Types

type GetDocumentFromURLOption

type GetDocumentFromURLOption func(awsCfg *aws.Config, httpClient *http.Client)

GetDocumentFromURLOption is a type alias for a function that can set various options to GetDocumentFromURL.

func WithAWSDisableSSL

func WithAWSDisableSSL(disableSSL bool) GetDocumentFromURLOption

WithAWSDisableSSL is an option for GetDocumentFromURL to optionally disable SSL for requests.

func WithAWSEndpoint

func WithAWSEndpoint(endpoint string) GetDocumentFromURLOption

WithAWSEndpoint is an option for GetDocumentFromURL to set the AWS service endpoint.

func WithAWSRegion

func WithAWSRegion(region string) GetDocumentFromURLOption

WithAWSRegion is an option for GetDocumentFromURL to set the AWS region.

func WithAWSStaticCredentials

func WithAWSStaticCredentials(accessKey, secretKey, token string) GetDocumentFromURLOption

WithAWSStaticCredentials is an option for GetDocumentFromURL to set AWS credentials.

func WithHTTPTimeout

func WithHTTPTimeout(timeout time.Duration) GetDocumentFromURLOption

WithHTTPTimeout is an option for GetDocumentFromURL to set the HTTP timeout.

Jump to

Keyboard shortcuts

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