Skip to content

Examples

Check out the complete examples in the example/ directory of the MoniGo repository.

Located in example/security-examples/:

  • Basic Authentication (basic-auth/) - HTTP Basic Auth with rate limiting
  • API Key Authentication (api-key/) - API key via header or query parameter
  • IP Whitelist (ip-whitelist-example/) - IP-based access control with debug logging
  • Custom Authentication (custom-auth/) - Custom auth function with headers / query params
  • Gin (gin/) - Gin framework with security middleware
  • Echo (echo/) - Echo framework with security middleware
  • Fiber (fiber/) - Fiber framework with security middleware
  • Chi (chi/) - Chi router with security middleware

Each example has its own go.mod file and can be run independently:

Terminal window
# Basic example
cd example/router-integration
go run .
# Security example
cd example/security-examples/basic-auth
go run .
# Framework example
cd example/security-examples/gin
go run .
ExampleURLCredentials
Basic Authhttp://localhost:8080/admin / monigo-secure-2024
API Keyhttp://localhost:8080/?api_key=monigo-secret-key-2024-
IP Whitelisthttp://localhost:8080/localhost only
Custom Authhttp://localhost:8080/?secret=monigo-admin-secret-