utils

package
v0.7.17 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode[T any](s string, v *T) error

Decode is a function that decodes a base64-encoded string and then decodes the resulting JSON into a value of type T. Parameters:

  • s (string): The base64-encoded string to decode.
  • v (*T): A pointer to a value of type T to store the decoded JSON.

Returns:

  • error: An error message if the decoding fails, or nil if the decoding is successful.

func Error

func Error[T any](err T) []byte

Error is a function that returns an error message with the provided error. Parameters:

  • err (T): The error to include in the error message.

Returns:

  • []byte: A byte slice containing the error message with the provided error.

func GetJSONParam

func GetJSONParam[T any](ctx *fiber.Ctx, json *T) error

GetJSONParam is a function that retrieves a JSON-encoded value from a query parameter in a Fiber context and decodes it into a value of type T. Parameters:

  • ctx (*fiber.Ctx): A pointer to a Fiber context.
  • json (*T): A pointer to a value of type T to store the decoded JSON.

Returns:

  • error: An error message if the decoding fails or the query parameter is invalid, or nil if the decoding is successful.

func GetLimitParam

func GetLimitParam(ctx *fiber.Ctx, limit *int) error

GetLimitParam is a function that retrieves the "limit" query parameter from a Fiber context and stores it in an integer pointer. Parameters:

  • ctx (*fiber.Ctx): A pointer to a Fiber context.
  • limit (*int): A pointer to an integer to store the "limit" query parameter.

Returns:

  • error: An error message if the "limit" query parameter is invalid or cannot be converted to an integer, or nil if the retrieval is successful.

func GetMaxBytesParam

func GetMaxBytesParam(ctx *fiber.Ctx, maxBytes *int) error

GetMaxBytesParam is a function that retrieves the "maxbytes" query parameter from a Fiber context and stores it in an integer pointer. Parameters:

  • ctx (*fiber.Ctx): A pointer to a Fiber context.
  • maxBytes (*int): A pointer to an integer to store the "maxbytes" query parameter.

Returns:

  • error: An error message if the "maxbytes" query parameter is invalid or cannot be converted to an integer, or nil if the retrieval is successful.

func GetMaxSizeParam

func GetMaxSizeParam(ctx *fiber.Ctx, maxSize *int) error

GetMaxSizeParam is a function that retrieves the "maxsize" query parameter from a Fiber context and stores it in an integer pointer. Parameters:

  • ctx (*fiber.Ctx): A pointer to a Fiber context.
  • maxSize (*int): A pointer to an integer to store the "maxsize" query parameter.

Returns:

  • error: An error message if the "maxsize" query parameter is invalid or cannot be converted to an integer, or nil if the retrieval is successful.

func GetMinWordLengthParam

func GetMinWordLengthParam(ctx *fiber.Ctx, minWordLength *int) error

Get the min word length url parameter

func GetSchemaParam

func GetSchemaParam(ctx *fiber.Ctx, schema *map[string]bool) error

GetSchemaParam is a function that retrieves a schema from a query parameter in a Fiber context and decodes it into a map of string keys and boolean values. Parameters:

  • ctx (*fiber.Ctx): A pointer to a Fiber context.
  • schema (*map[string]bool): A pointer to a map of string keys and boolean values to store the decoded schema.

Returns:

  • error: An error message if the decoding fails or the query parameter is invalid, or nil if the decoding is successful.

func GetStrictParam

func GetStrictParam(ctx *fiber.Ctx, strict *bool) error

GetLimitParam is a function that retrieves the "limit" query parameter from a Fiber context and stores it in an integer pointer. Parameters:

  • ctx (*fiber.Ctx): A pointer to a Fiber context.
  • limit (*int): A pointer to an integer to store the "limit" query parameter.

Returns:

  • error: An error message if the "limit" query parameter is invalid or cannot be converted to an integer, or nil if the retrieval is successful.

func GetValueParam

func GetValueParam[T any](ctx *fiber.Ctx, value *T) error

GetValueParam is a function that retrieves a value from a query parameter in a Fiber context and decodes it into a value of type T. Parameters:

  • ctx (*fiber.Ctx): A pointer to a Fiber context.
  • value (*T): A pointer to a value of type T to store the decoded value.

Returns:

  • error: An error message if the decoding fails or the query parameter is invalid, or nil if the decoding is successful.

func Success

func Success[T any](v T) []byte

Success is a function that returns a success message with the provided data. Parameters:

  • v (T): The data to include in the success message.

Returns:

  • []byte: A byte slice containing the success message with the provided data.

Types

This section is empty.

Jump to

Keyboard shortcuts

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