Skip to main content
Version: 2.10.x(Latest)

📄️ JWT Authentication

Demonstrates comprehensive JWT (JSON Web Token) authentication implementation in GoFrame HTTP servers for secure API access control. This example showcases JWT token generation with custom claims and expiration, token validation and verification middleware, secure token signing using HS256/RS256 algorithms, refresh token mechanism for extended sessions, protected route implementation with authentication middleware, error handling for invalid or expired tokens, and integration with GoFrame's middleware system. Features include user login and token issuance, stateless authentication, token refresh patterns, role-based access control (RBAC) integration, secure token storage recommendations, and production-ready security practices. Ideal for building REST APIs with authentication, implementing microservices security, mobile app backends requiring stateless auth, and applications needing scalable authentication without server-side sessions.

📄️ Basic Authentication

Demonstrates HTTP Basic Authentication implementation in GoFrame for simple credential-based access control. This example showcases Basic Authentication middleware setup and configuration, username and password validation against configured credentials, Base64 credential encoding and decoding, WWW-Authenticate header handling for browser prompts, protected route implementation, custom authentication failure responses, and integration with GoFrame's middleware system. Features include simple authentication without external dependencies, browser-compatible authentication dialogs, credential validation patterns, secure credential storage recommendations, custom realm configuration, and production-ready error handling. Ideal for internal tools and admin panels, simple API protection, development and testing environments, legacy system integration, and applications requiring lightweight authentication without complex infrastructure.

📄️ GoFrame MCP HTTP Example

Demonstrates Model Context Protocol (MCP) server implementation using GoFrame with HTTP streaming for AI model integration. This example showcases MCP server setup using HTTP transport, streaming response handling for real-time model outputs, protocol message encoding and decoding, context management and propagation, integration with AI models and services, and error handling for MCP operations. Features include HTTP-based MCP transport, streaming API support, efficient message serialization, context sharing between requests, extensible protocol handlers, and production-ready patterns. Ideal for building AI agent backends, integrating language models with applications, implementing streaming AI responses, and creating MCP-compliant services for model context sharing.

📄️ GoFrame MCP SSE Example

Demonstrates Model Context Protocol (MCP) server implementation using GoFrame with Server-Sent Events (SSE) for real-time AI model communication. This example showcases MCP server setup using SSE transport for server-to-client streaming, real-time event streaming for model outputs, persistent connections for continuous communication, event formatting and client reconnection handling, integration with AI models and agents, and efficient resource management. Features include SSE-based MCP transport, unidirectional streaming from server to client, automatic reconnection support, event-driven architecture, lightweight protocol implementation, and production-ready patterns. Ideal for building real-time AI agent interfaces, implementing streaming model responses without WebSocket complexity, creating chat and assistant applications, and enabling server-push notifications for model updates.

📄️ Proxy

Demonstrates reverse proxy server implementation using GoFrame for request forwarding and load distribution. This example showcases reverse proxy setup and configuration with target backend servers, HTTP request and response forwarding with header preservation, custom header manipulation and transformation, connection pooling and keepalive management, error handling and failover logic, and integration with GoFrame's middleware system. Features include flexible proxy configuration, transparent request forwarding, response streaming support, custom routing rules, load balancing integration, and production-ready patterns. Ideal for building API gateways and service proxies, implementing microservices routing, adding authentication and rate limiting layers, enabling A/B testing and canary deployments, and creating development proxy servers.

📄️ Rate Limit

Demonstrates rate limiting implementation in GoFrame HTTP servers for API protection and traffic control. This example showcases rate limiting middleware configuration with configurable limits, token bucket and sliding window algorithms, per-IP and per-user rate limiting strategies, custom rate limit responses and headers (X-RateLimit-*), Redis-based distributed rate limiting for scalability, and integration with GoFrame's middleware chain. Features include flexible rate limit policies, distributed rate limiting support, custom limit rules per endpoint, graceful rate limit responses, monitoring and metrics integration, and production-ready patterns. Ideal for protecting APIs from abuse and DDoS attacks, implementing fair usage policies, ensuring service stability under load, managing API quota and billing, and enabling multi-tier service levels.

📄️ Response with JSON Array

Demonstrates JSON array response handling in GoFrame HTTP servers for RESTful API development. This example showcases returning JSON arrays as HTTP responses, proper content-type header configuration, array serialization with custom formatting, pagination support for large datasets, efficient memory management for large arrays, and integration with GoFrame's response writing system. Features include automatic JSON marshaling, proper HTTP status codes, empty array handling, streaming support for large datasets, error response formatting, and RESTful API patterns. Ideal for building REST APIs returning collections, implementing list and search endpoints, handling bulk data responses, ensuring consistent API response formats, and optimizing JSON serialization performance.

📄️ Server-Sent Events(SSE)

Demonstrates Server-Sent Events (SSE) implementation using GoFrame for real-time server-to-client streaming. This example showcases SSE server setup with persistent connections, event stream formatting with data, event types and IDs, automatic client reconnection handling with Last-Event-ID, sending real-time updates and notifications, proper content-type and headers configuration, and connection lifecycle management. Features include unidirectional streaming from server to client, automatic reconnection support, event-driven architecture, lightweight compared to WebSocket, heartbeat and keepalive support, and production-ready patterns. Ideal for building real-time notifications and updates, implementing live dashboards and monitoring, creating chat and messaging features, enabling server push without WebSocket, and building event-driven applications.

📄️ Swagger Auth

Demonstrates Swagger API documentation with Basic Authentication integration using GoFrame for secure API documentation access. This example showcases Swagger UI integration with GoFrame HTTP server, Basic Authentication protection for Swagger endpoints, OpenAPI specification generation and serving, authentication middleware for documentation access, custom Swagger UI configuration, and integration with GoFrame's routing system. Features include protected API documentation, automatic OpenAPI spec generation, interactive API testing with authentication, customizable Swagger UI themes, credential-based access control, and development-friendly patterns. Ideal for securing API documentation in production, providing authenticated access to internal APIs, enabling interactive API testing with auth, documenting and protecting REST APIs, and maintaining API specifications with access control.

📄️ File Upload Example

Demonstrates file upload handling in GoFrame HTTP servers for multipart form data processing. This example showcases single and multiple file upload support, multipart form data parsing and processing, file size validation and limits, file type validation with MIME type checking, secure file storage with unique naming, and integration with GoFrame's request handling. Features include automatic file parsing, configurable upload limits, file metadata extraction, progress tracking support, error handling for invalid uploads, and production-ready patterns. Ideal for building file upload APIs and forms, implementing image and document upload features, handling bulk file uploads, ensuring secure file processing, and creating content management systems.

📄️ WebSocket

Demonstrates WebSocket server and client implementation using GoFrame for bidirectional real-time communication. This example showcases WebSocket server setup with connection handling, client connection establishment and management, bidirectional message sending and receiving, connection lifecycle management (connect, disconnect, error), protocol upgrade from HTTP to WebSocket, and integration with GoFrame's server components. Features include full-duplex communication, automatic ping/pong heartbeat, connection pooling and broadcasting, message framing and encoding, TLS/SSL support for secure WebSocket (wss://), and production-ready patterns. Ideal for building real-time chat and messaging applications, implementing live notifications and updates, creating multiplayer game servers, enabling collaborative editing features, and building real-time data streaming applications.