Categorygithub.com/gravitational/form
modulepackage
0.0.0-20221215172421-ca521a6428ea
Repository: https://github.com/gravitational/form.git
Documentation: pkg.go.dev

# README

Form

Build Status

Form is a package for handling HTTP web forms input. See godoc for details:

godoc github.com/gravitational/form

# Functions

Duration extracts duration expressed as a Go duration string e.g.
FileSlice reads the files uploaded with name parameter and initialized the slice of files.
Int extracts the integer argument in decimal format e.g.
Parse takes http.Request and form arguments that it needs to extract import ( "github.com/gravitational/form" ) var duration time.Duration var count int name := "default" // a simple way to set default argument err := form.Parse(r, form.Duration("duration", &duration), form.Int("count", &count, Required()), // notice the "Required" argument form.String("name", &name), ) if err != nil { // handle error here }.
Required checker parameter ensures that the parameter is indeed supplied by user it returns MissingParameterError when parameter is not present.
String extracts the argument by name as is without any changes.
StringSlice extracts the string slice of arguments by name.
Time extracts duration expressed as in RFC 3339 format.

# Structs

BadParameterError is returned whenever the parameter format does not match required restrictions.
No description provided by the author
No description provided by the author
MissingParameterError is an error that indicates that required parameter was not supplied by user.

# Interfaces

Predicate provides an extensible way to check various conditions on a variable e.g.

# Type aliases

Files is a slice of multipart.File that provides additional convenient method to close all files as a single operation.
Param is a functional argument parameter passed to the Parse function.
PredicateFunc takes a func and converts it into a Predicate-compatible interface.