form

package
v0.0.0-...-e041b52 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Copyright 2014 Alvaro J. Genial. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. nolint

Package form implements encoding and decoding of application/x-www-form-urlencoded data.

Copyright 2014 Alvaro J. Genial. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. nolint

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeToString

func EncodeToString(dst interface{}) (string, error)

EncodeToString encodes dst as a form and returns it as a string.

func EncodeToStringWith

func EncodeToStringWith(dst interface{}, d rune, e rune, z bool) (string, error)

EncodeToStringWith encodes dst as a form with delimiter d, escape e, keeping zero values if z, and returns it as a string.

func EncodeToValues

func EncodeToValues(dst interface{}) (url.Values, error)

EncodeToValues encodes dst as a form and returns it as Values.

func EncodeToValuesWith

func EncodeToValuesWith(dst interface{}, d rune, e rune, z bool) (url.Values, error)

EncodeToValuesWith encodes dst as a form with delimiter d, escape e, keeping zero values if z, and returns it as Values.

Types

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder provides a way to encode to a Writer.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns a new form Encoder.

func (*Encoder) DelimitWith

func (e *Encoder) DelimitWith(r rune) *Encoder

DelimitWith sets r as the delimiter used for composite keys by Encoder e and returns the latter; it is '.' by default.

func (Encoder) Encode

func (e Encoder) Encode(dst interface{}) error

Encode encodes dst as form and writes it out using the Encoder's Writer.

func (*Encoder) EscapeWith

func (e *Encoder) EscapeWith(r rune) *Encoder

EscapeWith sets r as the escape used for delimiters (and to escape itself) by Encoder e and returns the latter; it is '\\' by default.

func (*Encoder) KeepZeros

func (e *Encoder) KeepZeros(z bool) *Encoder

KeepZeros sets whether Encoder e should keep zero (default) values in their literal form when encoding, and returns the former; by default zero values are not kept, but are rather encoded as the empty string.

Jump to

Keyboard shortcuts

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