frankenphp/caddy/caddy_test.go
Kévin Dunglas 7d81fa51fe
feat: add a woker mode (#1)
* refactor: better memory management

* wip

* tmp

* introduce a go-like api

* upgraded to PHP 8.2

* Fix thread safety issues

* fix tests

* wip

* refactor worker

* worker prototype

* fix populate env

* session

* improve tests

* fix Caddy tests

* refactor
2022-05-18 11:52:24 +02:00

45 lines
881 B
Go

package caddy_test
import (
"net/http"
"testing"
"github.com/caddyserver/caddy/v2/caddytest"
)
func TestPHP(t *testing.T) {
tester := caddytest.NewTester(t)
tester.InitServer(`
{
http_port 9080
https_port 9443
}
localhost:9080 {
route {
root * {env.PWD}/../testdata
# Add trailing slash for directory requests
@canonicalPath {
file {path}/index.php
not path */
}
redir @canonicalPath {path}/ 308
# If the requested file does not exist, try index files
@indexFiles file {
try_files {path} {path}/index.php index.php
split_path .php
}
rewrite @indexFiles {http.matchers.file.relative}
# Handle PHP files with FrankenPHP
@phpFiles path *.php
php @phpFiles
respond 404
}
}
`, "caddyfile")
tester.AssertGetResponse("http://localhost:9080", http.StatusOK, "I am by birth a Genevese")
}