envelope

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package envelope contains shared JSON request and response envelope contracts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EncryptedBody

type EncryptedBody struct {
	Data       string `json:"data" example:"encrypted-payload"`
	DeviceUUID string `json:"deviceUUID" example:"ADAD3-ADD33-AFSFK"`
}

EncryptedBody is the encrypted request/response envelope.

type ErrorResponse

type ErrorResponse struct {
	Header ResponseInfo `json:"header,omitempty"`
}

ErrorResponse documents an error response without a content payload.

func Error

func Error() ErrorResponse

Error returns an error response envelope.

type JSONRequest

type JSONRequest struct {
	Header  RequestInfo     `json:"header,omitempty"`
	Content json.RawMessage `json:"content,omitempty"`
}

JSONRequest is the runtime JSON request envelope.

type RequestInfo

type RequestInfo struct {
	UUID            string `json:"uuid,omitempty" example:"ADAD3-ADD33-AFSFK"`
	DeviceType      string `json:"device_type,omitempty" example:"phone"`
	DeviceBrand     string `json:"device_brand,omitempty" example:"Samsung"`
	DeviceModel     string `json:"device_model,omitempty" example:"A11"`
	OS              string `json:"os,omitempty" example:"android"`
	OSVersion       string `json:"os_version,omitempty" example:"14"`
	Lang            string `json:"lang,omitempty" example:"es"`
	Timezone        string `json:"timezone,omitempty" example:"America/Mexico_City"`
	AppVersion      string `json:"app_version,omitempty" example:"3.0.0"`
	AppBuildVersion string `json:"app_build_version,omitempty" example:"1.0.0.10"`
	AppName         string `json:"app_name,omitempty" example:"My App"`
	SecurityToken   string `json:"token,omitempty" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"`
	DeviceId        string `json:"device_id,omitempty" example:"device-123"`
	DeviceSerial    string `json:"device_serial,omitempty" example:"serial-123"`
	Latitude        string `json:"lat,omitempty" example:"19.4326"`
	Longitude       string `json:"lon,omitempty" example:"-99.1332"`
}

RequestInfo contains request header metadata.

type RequestOf

type RequestOf[T any] struct {
	Header  RequestInfo `json:"header,omitempty"`
	Content *T          `json:"content,omitempty"`
}

RequestOf documents a request envelope with a concrete content payload type.

func Request

func Request[T any]() RequestOf[T]

Request returns a typed request envelope.

type Response

type Response struct {
	Header  ResponseInfo `json:"header,omitempty"`
	Content any          `json:"content,omitempty"`
}

Response is the runtime JSON response envelope.

type ResponseInfo

type ResponseInfo struct {
	Type    core.ResponseType `json:"type" example:"success"`
	Title   string            `json:"title,omitempty" example:"Success"`
	Message string            `json:"message,omitempty" example:"Operation completed"`
	Code    string            `json:"code,omitempty" example:"OK"`
	Token   string            `json:"token,omitempty" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"`
	Action  string            `json:"action,omitempty" example:"refresh"`
	EventID string            `json:"event_id,omitempty" example:"f716243f2c92df55fcd8f67018b1dcfb"`
	Info    map[string]string `json:"info,omitempty" example:"{\"field\":\"value\"}"`
}

ResponseInfo contains response header metadata.

type ResponseOf

type ResponseOf[T any] struct {
	Header  ResponseInfo `json:"header,omitempty"`
	Content *T           `json:"content,omitempty"`
}

ResponseOf documents a response envelope with a concrete content payload type.

func Success

func Success[T any]() ResponseOf[T]

Success returns a typed response envelope.

Jump to

Keyboard shortcuts

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