httplib

package
v0.0.0-...-3288de0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCSV

func GetCSV(qs url.Values, key string, def []string) []string

Returns multiple string values from query params.

func GetDate

func GetDate(qs url.Values, key string, def time.Time) (time.Time, error)

Returns an time value from query params. Must be in the format YYYY-MM-DD.

func GetInt

func GetInt(qs url.Values, key string, def int) (int, error)

func GetString

func GetString(qs url.Values, key, def string) string

Returns a string value from query params.

func ReadJSON

func ReadJSON(w http.ResponseWriter, r *http.Request, v any) error

Reads a JSON-encoded value from the request body and stores it in the value pointed to by v.

func URLIntParam

func URLIntParam(r *http.Request, key string) (int64, error)

Tries to get a int value from url params.

func URLParam

func URLParam(r *http.Request, key string) string

Gets a url param from the request.

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, v any) error

Writes the JSON encoding of v to the http.ResponseWriter.

Types

type M

type M map[string]any

Helper map for enveloping responses

Jump to

Keyboard shortcuts

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