{"modulePath":"github.com/hyperhq/hypercli","version":"v1.10.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package httputils\n\n## Constants\n\n```go\nconst APIVersionKey = \"api-version\"\n```\nAPIVersionKey is the client's requested API version.\n\n## Functions\n\n```go\nfunc BoolValue(r *http.Request, k string) bool\n```\nBoolValue transforms a form value in different formats into a boolean type.\n\n```go\nfunc BoolValueOrDefault(r *http.Request, k string, d bool) bool\n```\nBoolValueOrDefault returns the default bool passed if the query param is missing, otherwise it's just a proxy to boolValue above\n\n```go\nfunc CheckForJSON(r *http.Request) error\n```\nCheckForJSON makes sure that the request's Content-Type is application/json.\n\n```go\nfunc CloseStreams(streams ...interface{})\n```\nCloseStreams ensures that a list for http streams are properly closed.\n\n```go\nfunc HijackConnection(w http.ResponseWriter) (io.ReadCloser, io.Writer, error)\n```\nHijackConnection interrupts the http response writer to get the underlying connection and operate with it.\n\n```go\nfunc Int64ValueOrDefault(r *http.Request, field string, def int64) (int64, error)\n```\nInt64ValueOrDefault parses a form value into an int64 type. If there is an error, returns the error. If there is no value returns the default value.\n\n```go\nfunc Int64ValueOrZero(r *http.Request, k string) int64\n```\nInt64ValueOrZero parses a form value into an int64 type. It returns 0 if the parsing fails.\n\n```go\nfunc ParseForm(r *http.Request) error\n```\nParseForm ensures the request form is parsed even with invalid content types. If we don't do this, POST method without Content-type (even with empty body) will fail.\n\n```go\nfunc ParseMultipartForm(r *http.Request) error\n```\nParseMultipartForm ensure the request form is parsed, even with invalid content types.\n\n```go\nfunc VersionFromContext(ctx context.Context) (ver version.Version)\n```\nVersionFromContext returns an API version from the context using APIVersionKey. It panics if the context value does not have version.Version type.\n\n```go\nfunc WriteError(w http.ResponseWriter, err error)\n```\nWriteError decodes a specific docker error and sends it in the response.\n\n```go\nfunc WriteJSON(w http.ResponseWriter, code int, v interface{}) error\n```\nWriteJSON writes the value v to the http response stream as json with standard json encoding.\n\n## Types\n\n```go\ntype APIFunc func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error\n```\nAPIFunc is an adapter to allow the use of ordinary functions as Docker API endpoints. Any function that has the appropriate signature can be register as a API endpoint (e.g. getVersion).\n\n```go\ntype ArchiveOptions struct {\n\tName string\n\tPath string\n}\n```\nArchiveOptions stores archive information for different operations.\n\n```go\nfunc ArchiveFormValues(r *http.Request, vars map[string]string) (ArchiveOptions, error)\n```\nArchiveFormValues parses form values and turns them into ArchiveOptions. It fails if the archive name and path are not in the request.\n\n","path":"github.com/hyperhq/hypercli/api/server/httputils","name":"httputils","synopsis":"","isRedistributable":true}
