From c3048b175c1f8f1d62bb2d5d0100e9a03441b914 Mon Sep 17 00:00:00 2001 From: arisnguyenit97 Date: Mon, 9 Dec 2024 23:43:42 +0700 Subject: [PATCH] :recycle: refactor: update codebase #2 --- types.go | 80 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/types.go b/types.go index 5ccec3f..6024ee3 100644 --- a/types.go +++ b/types.go @@ -2,46 +2,6 @@ package wrapify import "time" -// pagination represents pagination details for paginated API responses. -type pagination struct { - page int // Current page number. - perPage int // Number of items per page. - totalPages int // Total number of pages. - totalItems int // Total number of items available. - isLast bool // Indicates whether this is the last page. -} - -// meta represents metadata information about an API response. -type meta struct { - apiVersion string // API version used for the request. - requestID string // Unique identifier for the request, useful for debugging. - locale string // Locale used for the request, e.g., "en-US". - requestedTime time.Time // Timestamp when the request was made. - customFields map[string]interface{} // Additional custom metadata fields. -} - -// header represents a structured header for API responses. -type header struct { - code int // Application-specific status code. - text string // Human-readable status text. - Type string // Type or category of the status, e.g., "info", "error". - description string // Detailed description of the status. -} - -// wrapper is the main structure for wrapping API responses, including metadata, data, and debugging information. -type wrapper struct { - statusCode int // HTTP status code for the response. - total int // Total number of items (used in non-paginated responses). - message string // A message providing additional context about the response. - data interface{} // The primary data payload of the response. - path string // Request path for which the response is generated. - header *header // Structured header details for the response. - meta *meta // Metadata about the API response. - pagination *pagination // Pagination details, if applicable. - debug map[string]interface{} // Debugging information (useful for development). - errors error // Internal errors (not exposed in JSON responses). -} - // Frame represents a program counter inside a stack frame. // A `Frame` is essentially a single point in the stack trace, // representing a program counter (the location in code) at the @@ -83,6 +43,46 @@ type Frame uintptr // fmt.Println(trace) // Prints the stack trace with the frames type StackTrace []Frame +// pagination represents pagination details for paginated API responses. +type pagination struct { + page int // Current page number. + perPage int // Number of items per page. + totalPages int // Total number of pages. + totalItems int // Total number of items available. + isLast bool // Indicates whether this is the last page. +} + +// meta represents metadata information about an API response. +type meta struct { + apiVersion string // API version used for the request. + requestID string // Unique identifier for the request, useful for debugging. + locale string // Locale used for the request, e.g., "en-US". + requestedTime time.Time // Timestamp when the request was made. + customFields map[string]interface{} // Additional custom metadata fields. +} + +// header represents a structured header for API responses. +type header struct { + code int // Application-specific status code. + text string // Human-readable status text. + Type string // Type or category of the status, e.g., "info", "error". + description string // Detailed description of the status. +} + +// wrapper is the main structure for wrapping API responses, including metadata, data, and debugging information. +type wrapper struct { + statusCode int // HTTP status code for the response. + total int // Total number of items (used in non-paginated responses). + message string // A message providing additional context about the response. + data interface{} // The primary data payload of the response. + path string // Request path for which the response is generated. + header *header // Structured header details for the response. + meta *meta // Metadata about the API response. + pagination *pagination // Pagination details, if applicable. + debug map[string]interface{} // Debugging information (useful for development). + errors error // Internal errors (not exposed in JSON responses). +} + // stack represents a stack of program counters. It is a slice of `uintptr` // values that store the addresses (or locations) of program counters // from a function call stack. This is useful for tracking where errors