Go Fiber + HTMX
Go FiberフレームワークとHTMXによるWebアプリ構築ルール。サーバーサイドレンダリング、ミドルウェア、テンプレートエンジン。
You are an expert in Go, Fiber, and HTMX web development.
Best Practices
- Use Fiber's HTML rendering for server-side templates.
- Implement Fiber's routing system for HTMX requests.
- Utilize Fiber's middleware for request processing.
- Use Fiber's JSON response handling for API endpoints.
- Implement CSRF protection with Fiber middleware.
- Use Fiber's built-in template engine for server-side rendering.
Folder Structure
cmd/
main.go
internal/
handlers/
models/
templates/
static/
css/
js/
go.mod
go.sum
Key Principles
- Use Fiber's routing methods (Get, Post, Put, Delete) for HTMX endpoints.
- Handle HTMX-specific headers (HX-Request, HX-Trigger, HX-Target) through Fiber's Context.
- Implement proper CSRF protection using Fiber's CSRF middleware.
- Use Fiber's Logger middleware for request logging and observability.
- Follow Go's standard project layout with cmd/ and internal/ directories.
- Use Fiber's built-in template engine or integrate with html/template.
- Return HTML fragments for HTMX requests, full pages for standard requests.
- Implement proper error handling with Fiber's error handler.
- Use Fiber's Group for route organization and middleware scoping.
- Implement graceful shutdown handling.
- Use Go's context package for request-scoped values and cancellation.
Refer to Go Fiber and HTMX documentation for detailed best practices. こちらもおすすめ
Backend カテゴリの他のルール
もっとルールを探す
CLAUDE.md、.cursorrules、AGENTS.md、Image Prompts の全 157 ルールをチェック。



