utils

package
v1.37.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: Apache-2.0 Imports: 6 Imported by: 19

Documentation

Index

Constants

View Source
const (
	// NetworkModeAWSVPC specifies the AWS VPC network mode.
	NetworkModeAWSVPC = "awsvpc"

	// RequestTypeCreds specifies the request type of CredentialsHandler.
	RequestTypeCreds = "credentials"

	// RequestTypeTaskMetadata specifies the task metadata request type of TaskContainerMetadataHandler.
	RequestTypeTaskMetadata = "task metadata"

	// RequestTypeContainerMetadata specifies the container metadata request type of TaskContainerMetadataHandler.
	RequestTypeContainerMetadata = "container metadata"

	// RequestTypeTaskStats specifies the task stats request type of StatsHandler.
	RequestTypeTaskStats = "task stats"

	// RequestTypeContainerStats specifies the container stats request type of StatsHandler.
	RequestTypeContainerStats = "container stats"

	// RequestTypeAgentMetadata specifies the Agent metadata request type of AgentMetadataHandler.
	RequestTypeAgentMetadata = "agent metadata"

	// RequestTypeContainerAssociations specifies the container associations request type of ContainerAssociationsHandler.
	RequestTypeContainerAssociations = "container associations"

	// RequestTypeContainerAssociation specifies the container association request type of ContainerAssociationHandler.
	RequestTypeContainerAssociation = "container association"

	// AnythingButSlashRegEx is a regex pattern that matches any string without slash.
	AnythingButSlashRegEx = "[^/]*"

	// AnythingRegEx is a regex pattern that matches anything.
	AnythingRegEx = ".*"

	// AnythingButEmptyRegEx is a regex pattern that matches anything but an empty string.
	AnythingButEmptyRegEx = ".+"
)

Variables

This section is empty.

Functions

func ConstructMuxVar

func ConstructMuxVar(name string, pattern string) string

ConstructMuxVar constructs the mux var that is used in the gorilla/mux styled path, example: {id}, {id:[0-9]+}.

func GetMuxValueFromRequest

func GetMuxValueFromRequest(r *http.Request, gorillaMuxName string) (string, bool)

GetMuxValueFromRequest extracts the mux value from the request using a gorilla mux name

func LimitReachedHandler

func LimitReachedHandler(auditLogger audit.AuditLogger) func(http.ResponseWriter, *http.Request)

LimitReachedHandler logs the throttled request in the credentials audit log

func ValueFromRequest

func ValueFromRequest(r *http.Request, field string) (string, bool)

ValueFromRequest returns the value of a field in the http request. The boolean value is set to true if the field exists in the query.

func WriteJSONToResponse

func WriteJSONToResponse(w http.ResponseWriter, httpStatusCode int, responseJSON []byte, requestType string)

WriteJSONToResponse writes the header, JSON response to a ResponseWriter, and log the error if necessary.

Types

type DockerStateResolver

type DockerStateResolver interface {
	State() dockerstate.TaskEngineState
}

DockerStateResolver is a sub-interface for the engine.TaskEngine interface to make it easy to test code in this package

type ErrorMessage

type ErrorMessage struct {
	Code          string `json:"code"`
	Message       string `json:"message"`
	HTTPErrorCode int
}

ErrorMessage is used to store the human-readable error Code and a descriptive Message that describes the error. This struct is marshalled and returned in the HTTP response.

Jump to

Keyboard shortcuts

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