Repository navigation
Conversation
…ッダでも渡す NativeDispatcher / NativeProxy が CgiRunner に直接依存していたのを、 NativeRunner インターフェースに依存させる。CgiRunner はその実装の一つ になる。FrankenPHP に組み込んだ Go 拡張で middleware.go を呼ぶ Runner (#143)を、ディスパッチの規則に触らずに差し込むための下ごしらえ。 あわせて、middleware.go に渡す matched pattern をリクエストヘッダ Relayer-Matched-Pattern でも渡す。同じプロセスで複数のリクエストを 処理するハンドラは、環境変数からリクエストごとの値を受け取れないため。 クライアントが送った同名のヘッダは置き換え、後ろのルートには渡さない。 環境変数 RELAYER_MATCHED_PATTERN は残すが非推奨にする。 Refs #143 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#143 の PR 1。
middleware.goを FrankenPHP に組み込んだ Go 拡張から呼ぶ Runner を、次の PR で差し込むための下ごしらえ。変更
NativeRunnerインターフェースを追加した。NativeDispatcher/NativeProxyはCgiRunnerではなくこのインターフェースに依存する。今の実装はCgiRunnerだけで、NativeDispatcher::forProject()も引き続きCgiRunnerを作るので、挙動は変わらないRelayer-Matched-Patternでも渡すようにした。**Go 側ではr.Header.Get("Relayer-Matched-Pattern")で読めるRELAYER_MATCHED_PATTERNは残すが、非推奨にした(@deprecatedと README)補足
PHP の
proc_open()は、値が空の環境変数を子プロセスに渡さない。そのため 404 のとき、CGI ではRELAYER_MATCHED_PATTERNも新しいヘッダも「空」ではなく「未設定」になる(今までも同じだった)。Go のos.Getenv/r.Header.Getはどちらも""を返すので、ハンドラから見た違いは無い。テストのコメントにも書いた。テスト
NativeProxyTestにテストを追加した:ヘッダで値が届く、404 では空になる、クライアントが送ったヘッダは置き換えられる、後ろのルートにはヘッダが渡らない、渡したNativeRunnerが使われるNativeMiddlewareDispatchTest(実際に Go をビルドして動かす)で、r.Header.Get("Relayer-Matched-Pattern")で値を読めることも確かめたphpunit(1511 件。skip の 1 件は以前からあるResponseTestのもの)、phpstan analyse、php-cs-fixer fix --dry-runはすべて通るRefs #143
🤖 Generated with Claude Code