payload

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: GPL-3.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package payload encodes portable callback button data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeCompact

func EncodeCompact(p Payload) (string, error)

EncodeCompact encodes a payload into a URL-safe compact callback string.

func EncodeJSON

func EncodeJSON(p Payload) (string, error)

EncodeJSON encodes a payload for adapters that accept JSON callback data.

Types

type Payload

type Payload struct {
	Namespace string         `json:"n"`
	Action    string         `json:"a"`
	Data      map[string]any `json:"d,omitempty"`
}

Payload identifies a callback route and its optional data.

func DecodeCompact

func DecodeCompact(s string) (Payload, error)

DecodeCompact decodes a compact callback string.

func DecodeJSON

func DecodeJSON(s string) (Payload, error)

DecodeJSON decodes a JSON callback payload.

func New

func New(namespace, action string, data map[string]any) Payload

New creates a callback payload.

func (Payload) Route

func (p Payload) Route() string

Route returns namespace.action, or action when namespace is empty.

Jump to

Keyboard shortcuts

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