commons

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContextFromRequest

func NewContextFromRequest(r *http.Request) context.Context

NewContextFromRequest provides a new context including a trxId from the request or if missing, a brand new trxId.

func ValidateEndpoint

func ValidateEndpoint(endpoint string) error

ValidateEndpoints provides url/uri level validation, it does not make any actual http(s) requests

func ValidateUUID

func ValidateUUID(u string) error

ValidateUUID checks the uuid string for supported formats

func WriteJSONMessage

func WriteJSONMessage(w http.ResponseWriter, status int, msg string) error

WriteJSONMessage writes the msg provided as encoded json with the proper content type header added.

Types

type Endpoint

type Endpoint interface {
	// Endpoint
	// Returns the endpoint
	Endpoint() string

	// IsValid
	// Validates the structure of the url/uri(s)
	IsValid() error

	// IsGTG
	// Checks if this endpoint is actually reachable and performing as expected
	IsGTG(ctx context.Context) (string, error)
}

Common type/behaviour definition for an endpoint

Jump to

Keyboard shortcuts

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