Skip to content

Commit a724832

Browse files
vishrclaude
andcommitted
Update website documentation to reflect current Echo v4 state
- Updated Go version requirement from 1.13 to 1.20 in quick-start guide - Enhanced Hello World example with proper middleware setup - Improved introduction to focus on examples repository purpose - Added comprehensive example categorization and better resource links - Enhanced graceful shutdown documentation with implementation details - Improved JWT authentication cookbook with clearer feature descriptions - Added CLAUDE.md file for future development guidance 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent ef985a7 commit a724832

File tree

5 files changed

+143
-35
lines changed

5 files changed

+143
-35
lines changed

CLAUDE.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Echo Extra (echox) is a collection of examples and recipes for the Echo web framework in Go. This repository contains:
8+
9+
- **cookbook/**: Complete example applications demonstrating various Echo features (22 examples including JWT, CORS, WebSocket, file upload/download, graceful shutdown, etc.)
10+
- **website/**: Docusaurus-based documentation website
11+
12+
## Development Commands
13+
14+
### Go Development
15+
```bash
16+
# Run tests with race detection
17+
go test -race ./...
18+
19+
# Or use the Makefile
20+
make test
21+
22+
# Run individual cookbook examples
23+
cd cookbook/<example-name>
24+
go run server.go
25+
```
26+
27+
### Website Development
28+
```bash
29+
# Navigate to website directory first
30+
cd website
31+
32+
# Install dependencies
33+
npm install
34+
35+
# Start development server (http://localhost:3000)
36+
npm start
37+
38+
# Build for production
39+
npm run build
40+
41+
# Serve built site
42+
npm run serve
43+
44+
# Alternative: run website in Docker
45+
make serve
46+
# or
47+
docker run --rm -it --name echo-docs -v ${PWD}/website:/home/app -w /home/app -p 3000:3000 -u node node:lts /bin/bash -c "npm install && npm start -- --host=0.0.0.0"
48+
```
49+
50+
## Architecture
51+
52+
### Cookbook Structure
53+
Each cookbook example is a standalone Go application in its own directory under `cookbook/`. Examples follow a consistent pattern:
54+
- `server.go` - Main application entry point using Echo v4
55+
- Additional files for complex examples (handlers, models, etc.)
56+
- Standard Echo patterns: middleware setup, route definitions, handler functions
57+
58+
### Key Dependencies
59+
- **Echo v4** (`github.com/labstack/echo/v4`) - Core web framework
60+
- **JWT libraries** - Multiple JWT implementations for authentication examples
61+
- **WebSocket** (`github.com/gorilla/websocket`) - Real-time communication
62+
- **Go 1.20+** - Minimum Go version requirement
63+
64+
### Website Architecture
65+
- **Docusaurus 3.1.0** - Static site generator
66+
- **React 18.2.0** - UI framework
67+
- **MDX** - Markdown with JSX support
68+
- Custom GitHub codeblock theme for syntax highlighting
69+
70+
## Development Workflow
71+
72+
1. **For cookbook examples**: Navigate to specific example directory and run `go run server.go`
73+
2. **For website changes**: Work in `website/` directory using npm commands
74+
3. **Testing**: Use `make test` or `go test -race ./...` to run all Go tests
75+
4. **Local preview**: Use `npm start` in website directory or `make serve` for Docker-based development
76+
77+
## Project Context
78+
79+
This is an examples/recipes repository rather than a library. Focus on:
80+
- Complete, runnable examples in cookbook/
81+
- Clear documentation and code comments
82+
- Following Echo v4 best practices and patterns
83+
- Maintaining consistency across examples

website/docs/cookbook/graceful-shutdown.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@ description: Graceful shutdown recipe
44

55
# Graceful Shutdown
66

7-
## Using [http.Server#Shutdown()](https://golang.org/pkg/net/http/#Server.Shutdown)
7+
This example demonstrates how to implement graceful shutdown using Go's `signal.NotifyContext` and Echo's `Shutdown` method to handle interrupt signals properly.
8+
9+
## Using [signal.NotifyContext](https://pkg.go.dev/os/signal#NotifyContext) and [Echo.Shutdown](https://pkg.go.dev/github.com/labstack/echo/v4#Echo.Shutdown)
810

911
```go reference
1012
https://github.com/labstack/echox/blob/master/cookbook/graceful-shutdown/server.go
1113
```
1214

15+
### Key Features
16+
17+
- Uses `signal.NotifyContext` to listen for OS interrupt signals (Ctrl+C)
18+
- Starts the server in a goroutine to allow non-blocking execution
19+
- Implements a 10-second timeout for graceful shutdown
20+
- Properly handles server shutdown errors
21+
1322
:::note
1423

15-
Requires go1.16+
24+
Requires Go 1.16+ for `signal.NotifyContext`. For earlier versions, use `signal.Notify` with a channel.
1625

1726
:::

website/docs/cookbook/jwt.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
---
2-
description: JWT recipe
2+
description: JWT authentication examples
33
---
44

5-
# JWT
5+
# JWT Authentication
66

7-
[JWT middleware](../middleware/jwt.md) configuration can be found [here](../middleware/jwt.md#configuration).
7+
This cookbook demonstrates JWT (JSON Web Token) authentication patterns using Echo's JWT middleware. Examples include both basic authentication flows and advanced usage with custom claims and key functions.
8+
9+
**Key Features:**
10+
- JWT authentication using HS256 algorithm
11+
- Token retrieval from `Authorization` request header
12+
- Custom claims handling
13+
- User-defined key functions for advanced scenarios
814

9-
This is cookbook for:
10-
- JWT authentication using HS256 algorithm.
11-
- JWT is retrieved from `Authorization` request header.
15+
[JWT middleware](../middleware/jwt.md) configuration can be found [here](../middleware/jwt.md#configuration).
1216

1317
## Server
1418

website/docs/guide/quick-start.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,14 @@ sidebar_position: 1
1010

1111
### Requirements
1212

13-
To install Echo [Go](https://go.dev/doc/install) 1.13 or higher is required. Go 1.12 has limited support and some middlewares will not be available. Make sure your project folder is outside your $GOPATH.
13+
To install Echo [Go](https://go.dev/doc/install) 1.20 or higher is required. Make sure your project folder is outside your $GOPATH and uses Go modules.
1414

1515
```sh
1616
$ mkdir myapp && cd myapp
1717
$ go mod init myapp
1818
$ go get github.com/labstack/echo/v4
1919
```
2020

21-
If you are working with Go v1.14 or earlier use:
22-
23-
```sh
24-
$ GO111MODULE=on go get github.com/labstack/echo/v4
25-
```
26-
2721
## Hello, World!
2822

2923
Create `server.go`
@@ -33,15 +27,25 @@ package main
3327

3428
import (
3529
"net/http"
36-
30+
3731
"github.com/labstack/echo/v4"
32+
"github.com/labstack/echo/v4/middleware"
3833
)
3934

4035
func main() {
36+
// Echo instance
4137
e := echo.New()
38+
39+
// Middleware
40+
e.Use(middleware.Logger())
41+
e.Use(middleware.Recover())
42+
43+
// Routes
4244
e.GET("/", func(c echo.Context) error {
4345
return c.String(http.StatusOK, "Hello, World!")
4446
})
47+
48+
// Start server
4549
e.Logger.Fatal(e.Start(":1323"))
4650
}
4751
```

website/docs/introduction.md

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,38 @@ slug: /
55

66
# Introduction
77

8-
## ![LabStack](../static/img/labstack-icon.png) Echo Project
8+
## ![LabStack](../static/img/labstack-icon.png) Echo Examples
99

10-
The Echo project is a powerful and versatile web framework for building scalable and high-performance web applications in the Go programming language. It follows the principles of simplicity, flexibility, and performance to provide developers with an efficient toolkit for building robust web applications.
10+
Echo Examples (echox) provides a comprehensive collection of practical examples and recipes for the Echo web framework. This repository demonstrates real-world usage patterns and best practices for building high-performance web applications with Echo v4.
1111

12-
## Key Features
12+
## What You'll Find Here
1313

14-
- **Fast and Lightweight**: Echo is designed for speed and efficiency, ensuring minimal overhead and high performance for handling HTTP requests and responses.
15-
- **Routing**: The framework offers a flexible and intuitive routing system that allows developers to define routes with parameters, query strings, and custom handlers.
16-
- **Middleware Support**: Echo provides extensive middleware support, enabling developers to easily implement cross-cutting concerns such as logging, authentication, error handling, and more.
17-
- **Context-based Request Handling**: With its context-based request handling, Echo offers easy access to request-specific data and parameters, simplifying the development of web applications.
18-
- **Powerful Template Rendering**: Echo includes a powerful template rendering engine that supports various template languages, allowing developers to generate dynamic HTML content effortlessly.
19-
- **Validation and Binding**: The framework provides robust validation and data binding capabilities, making it straightforward to validate incoming request data and bind it to Go structs.
20-
- **Extensibility**: Echo is highly extensible, with support for custom middleware, template engines, and other components, enabling developers to tailor the framework to their specific needs.
21-
- **Community and Ecosystem**: The Echo project benefits from a vibrant and active community that contributes libraries, plugins, and extensions, fostering an ecosystem of reusable components.
14+
- **22 Complete Examples**: From basic "Hello World" to advanced features like JWT authentication, WebSocket connections, and graceful shutdown
15+
- **Real-World Patterns**: Practical implementations of common web development scenarios
16+
- **Best Practices**: Production-ready code following Echo v4 conventions
17+
- **Modern Go**: Examples using Go 1.20+ features and current idiomatic patterns
2218

23-
## Resources and Documentation
19+
## Example Categories
20+
21+
- **Authentication & Security**: JWT, CORS, basic auth implementations
22+
- **File Operations**: Upload, download, and static file serving
23+
- **Real-time Communication**: WebSocket examples
24+
- **Advanced Routing**: Subdomain routing, reverse proxy, load balancing
25+
- **Deployment**: Auto TLS, Google App Engine, graceful shutdown
26+
- **Data Handling**: CRUD operations, form processing, JSON/XML binding
2427

25-
To learn more about the Echo project, you can refer to the following resources:
28+
## Getting Started
2629

27-
- Official Website: [https://echo.labstack.com](https://echo.labstack.com)
28-
- GitHub Repository: [https://github.com/labstack/echo](https://github.com/labstack/echo)
29-
- Documentation: [https://echo.labstack.com/docs](https://echo.labstack.com/guide)
30-
- Community Forum: [https://github.com/labstack/echo/discussions](https://github.com/labstack/echo/discussions)
30+
1. **Browse Examples**: Explore the cookbook section to find examples relevant to your use case
31+
2. **Run Locally**: Each example can be run independently with `go run server.go`
32+
3. **Learn Patterns**: Study the implementation patterns and adapt them to your projects
33+
34+
## Resources and Documentation
3135

32-
The Echo project offers an array of features that empower developers to build robust web applications. Its fast and lightweight nature ensures optimal performance, while the flexible routing system and middleware support streamline development processes. Developers can leverage the context-based request handling, powerful template rendering, and validation capabilities to create dynamic and secure web applications. Additionally, the extensibility of Echo allows developers to customize and enhance the framework to suit their specific needs.
36+
- **Echo Framework**: [https://echo.labstack.com](https://echo.labstack.com)
37+
- **Echo GitHub**: [https://github.com/labstack/echo](https://github.com/labstack/echo)
38+
- **Examples Repository**: [https://github.com/labstack/echox](https://github.com/labstack/echox)
39+
- **Community Discussions**: [https://github.com/labstack/echo/discussions](https://github.com/labstack/echo/discussions)
40+
- **API Documentation**: [https://pkg.go.dev/github.com/labstack/echo/v4](https://pkg.go.dev/github.com/labstack/echo/v4)
3341

34-
Join the vibrant community of Echo developers, explore the vast ecosystem of plugins and extensions, and unleash the power of Echo for your web development needs.
42+
Each example in this collection demonstrates production-ready code that you can use as a foundation for your own applications. The examples cover common web development scenarios and showcase Echo's capabilities in real-world contexts.

0 commit comments

Comments
 (0)