Skip to content

Add conditional routes example#198

Open
prajwalscodestack wants to merge 1 commit into
gin-gonic:masterfrom
prajwalscodestack:add-conditional-routes-example
Open

Add conditional routes example#198
prajwalscodestack wants to merge 1 commit into
gin-gonic:masterfrom
prajwalscodestack:add-conditional-routes-example

Conversation

@prajwalscodestack

Copy link
Copy Markdown

Description

This PR adds a new example demonstrating conditional route registration in Gin.

The example shows how routes can be enabled or disabled at application startup using command-line flags and environment variables.

Motivation

In production applications, it is common to conditionally expose:

  • Admin APIs
  • Metrics endpoints
  • Debug endpoints
  • Experimental features

This example demonstrates a simple and maintainable approach for registering routes based on configuration.

Example Usage

go run main.go --admin

or

ENABLE_METRICS=true go run main.go

Changes

  • Added conditional-routes example
  • Added README with usage instructions
  • Added comments explaining the pattern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant