// GetVarSafe is a helper function that returns the requested variable from URI with allowSet
// providing input sanitization. If an error occurs, returns either a `MissingFieldError`
// or an `UnsafeFieldError`.
GetVarSafe is a helper function that returns the requested variable from URI with allowSet
providing input sanitization. If an error occurs, returns either a `MissingFieldError`
or an `UnsafeFieldError`.
// GetVarSafe is a helper function that returns the requested variable from URI with allowSet // providing input sanitization . If an error occurs returns either a ` MissingFieldError ` // or an ` UnsafeFieldError ` .
func GetVarSafe(r *http.Request, variableName string, allowSet AllowSet) (string, error) {
	vars := mux.Vars(r)
	variableValue, ok := vars[variableName]
	if !ok {
		return "", MissingFieldError{variableName}
	}
	err := allowSet.IsSafe(variableValue)
	if err != nil {
		return "", UnsafeFieldError{variableName, err.Error()}
	}
	return variableValue, nil
}
func GetVarSafe ( r * http . Request , variableName string , allowSet AllowSet ) ( string , error ) { vars := mux . Vars ( r ) variableValue , ok := vars [ variableName ] if ! ok { return " " , MissingFieldError { variableName } } err := allowSet . IsSafe ( variableValue ) if err != nil { return " " , UnsafeFieldError { variableName , err . Error ( ) } } return variableValue , nil }
GetVarSafe is a helper function that returns the requested variable from URI with allowSet
providing input sanitization.
GetVarSafe is a helper function that returns the requested variable from URI with allowSet providing input sanitization .