basic

command
v0.3.0 Latest Latest
Warning

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

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

README

Basic Bifrost Example

This example demonstrates a simple Bifrost proxy setup with minimal configuration.

What This Example Shows

  • Loading configuration from a YAML file
  • Creating and starting a Bifrost proxy
  • Handling graceful shutdown on SIGINT/SIGTERM
  • Basic routing with path parameters

Running the Example

  1. Start some backend services (or use existing ones):
# Example: Simple HTTP server on port 3000
python3 -m http.server 3000 &

# Or use any existing service
  1. Update the configuration:

Edit config.yaml and replace the backend URLs with your actual services.

  1. Run the proxy:
go run main.go
  1. Test the proxy:
# Request will be proxied to http://localhost:3000/api/test
curl http://localhost:8080/api/test

# Request will be proxied to http://localhost:3001/v1/users/123
curl http://localhost:8080/users/123

# Health check endpoint (built-in)
curl http://localhost:8080/health
  1. Stop the proxy with Ctrl+C (SIGINT):

The proxy will gracefully shutdown, waiting for in-flight requests to complete.

Configuration Highlights

  • Port: The proxy listens on port 8080
  • Timeouts: Global 30s timeout, with route-specific overrides
  • Path Mapping: Routes can remap paths (e.g., /users/{id}/v1/users/{id})
  • Header Filtering: Only allowed headers are passed to backends
  • Body Size Limit: Requests larger than 10MB are rejected

Next Steps

  • See ../gcp-auth/ for GCP authentication examples
  • See ../programmatic/ for building configuration in code
  • See ../telemetry/ for OpenTelemetry integration

Documentation

Overview

Package main demonstrates a basic Bifrost proxy setup.

This example shows how to:

  • Load configuration from a YAML file
  • Create a Bifrost proxy instance
  • Start an HTTP server
  • Handle graceful shutdown

Jump to

Keyboard shortcuts

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