Files
everything-claude-code/docs/ja-JP/skills/tinystruct-patterns/references/routing.md
Claude 174e31b3fc feat(ja-JP): add skill sub-reference translations (angular, remotion, etc.)
Translated 85 skill sub-reference files to achieve full parity with
the English source:

- skills/angular-developer/references/ — 35 files (all references)
- skills/remotion-video-creation/rules/ — 28 files (all rules)
- skills/tinystruct-patterns/references/ — 5 files
- skills/openclaw-persona-forge/references/ — 6 files
- skills/skill-comply/prompts/ — 3 files
- skills/lead-intelligence/agents/ — 4 files
- skills/brand-voice/references/ — 1 file
- skills/frontend-slides/ — 2 files
- hooks/memory-persistence/README.md — 1 file

English source parity: 0 missing files (excluding rules/zh/, internal
docs, and experimental examples absent from zh-CN)
2026-05-18 06:15:26 +09:00

58 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# tinystruct @Action ルーティングリファレンス
## 使用場面
アプリケーションで `@Action`テーションを使用して、CLIコマンドとHTTPエンドポイントの両方にルートを定義します。特定のパスにロジックをマッピングする必要がある場合、パラメータ化されたリクエストを処理する場合IDによるリソースの取得、または特定のHTTPメソッドGET、POSTなどに実行を制限しながら、環境をまたいで一貫したコマンド構造を維持したい場合に適しています。
## 動作の仕組み
`ActionRegistry``@Action`テーションをパースしてルーティングテーブルを構築します。パラメータ化されたメソッドに対して、フレームワークはJavaパラメータ型int、Stringなどを対応するregexセグメントに自動的にマッピングして内部マッチングパターンを生成します。例えば、`getUser(int id)` は数字をターゲットとするregexを生成し、`search(String query)` は汎用のパスセグメントをターゲットとします。
リクエストがディスパッチされると、`ActionRegistry``Request``Response` のような依存関係が指定されている場合、現在のリクエストの `Context` から直接取り出してアクションメソッドに自動的にインジェクトします。実行はさらに `Mode` の値によってフィルタリングされ、単一のパスがターミナルコマンドか特定タイプのHTTPリクエストかによって異なるロジックを呼び出せます。
### Mode値
| Mode | トリガーされるタイミング |
|---|---|
| `DEFAULT` | CLIとHTTPの両方GET、POSTなど |
| `CLI` | CLIディスパッチャーのみ |
| `HTTP_GET` | HTTP GETのみ |
| `HTTP_POST` | HTTP POSTのみ |
| `HTTP_PUT` | HTTP PUTのみ |
| `HTTP_DELETE` | HTTP DELETEのみ |
| `HTTP_PATCH` | HTTP PATCHのみ |
## 例
### 基本的なアクション宣言
```java
@Action(
value = "path/subpath", // 必須URIセグメントまたはCLIコマンド
description = "何をするか", // --helpの出力に表示される
mode = Mode.HTTP_POST, // デフォルトMode.DEFAULTCLIとHTTPの両方
options = {}, // CLIオプションフラグ
example = "curl -X POST http://localhost:8080/path/subpath/42"
)
public String myAction(int id) { ... }
```
### パラメータ化されたパスRegex生成
```java
@Action("user/{id}")
public String getUser(int id) { ... }
// → パターン:^/?user/(-?\d+)$
@Action("search")
public String search(String query) { ... }
// → パターン:^/?search/([^/]+)$
```
### RequestとResponseのインジェクション
```java
@Action(value = "upload", mode = Mode.HTTP_POST)
public String upload(Request<?, ?> req, Response<?, ?> res) throws ApplicationException {
// req.getParameter("file"), res.setHeader(...), など
return "ok";
}
```