utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package utils provides common utility functions used across the API service These are generic, stateless helpers designed to simplify repetitive tasks and enforce consistent behaviors across multiple modules of the application

Key Features:

  • Standard NoRoute HTTP handler that returns a JSON 404 response
  • Reusable helper logic that doesn’t belong to any specific domain (e.g., string manipulation, error formatting)

The utils package is intended to be lightweight and static, meaning it can be imported and used without configuration or initialization. This makes it ideal for logic that is infrastructural rather than business-specific

Example Use:

// Attach NoRoute handler to a router like Gin
router.NoRoute(utils.NoRouteHandler)

The goal is to reduce code duplication and standardize how edge cases are handled, particularly in routing and error responses

Typical Use Cases:

  • Providing a fallback for unmatched API routes
  • Centralizing reusable helper logic to keep other packages focused

Note: Since the utils package aims to be generic and broadly applicable, it should not contain logic that introduces dependencies on business logic, middleware, or external services

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NoRouteHandler

func NoRouteHandler(c *gin.Context)

Handle requests with no route

Types

This section is empty.

Jump to

Keyboard shortcuts

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