Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ jobs:
if: matrix.php-versions == '8.5'
with:
version: latest
- name: Lint Caddy module Go code
uses: golangci/golangci-lint-action@v9
if: matrix.php-versions == '8.5'
with:
version: latest
working-directory: caddy/
- name: Ensure go.mod is tidy
if: matrix.php-versions == '8.5'
run: go mod tidy -diff
Expand Down
3 changes: 1 addition & 2 deletions caddy/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ func (admin *FrankenPHPAdmin) restartWorkers(w http.ResponseWriter, r *http.Requ

frankenphp.RestartWorkers()
caddy.Log().Info("workers restarted from admin api")
admin.success(w, "workers restarted successfully\n")

return nil
return admin.success(w, "workers restarted successfully\n")
}

func (admin *FrankenPHPAdmin) threads(w http.ResponseWriter, _ *http.Request) error {
Expand Down
5 changes: 3 additions & 2 deletions caddy/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/caddyserver/caddy/v2/caddytest"
"github.com/dunglas/frankenphp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestRestartWorkerViaAdminApi(t *testing.T) {
Expand Down Expand Up @@ -245,7 +246,7 @@ func getAdminResponseBody(t *testing.T, tester *caddytest.Tester, method string,
r, err := http.NewRequest(method, adminUrl+path, nil)
assert.NoError(t, err)
resp := tester.AssertResponseCode(r, http.StatusOK)
defer resp.Body.Close()
defer func() { require.NoError(t, resp.Body.Close()) }()
bytes, err := io.ReadAll(resp.Body)
assert.NoError(t, err)

Expand Down Expand Up @@ -319,7 +320,7 @@ func TestAddModuleWorkerViaAdminApi(t *testing.T) {
assert.NoError(t, err)
r.Header.Set("Content-Type", "text/caddyfile")
resp := tester.AssertResponseCode(r, http.StatusOK)
defer resp.Body.Close()
defer func() { require.NoError(t, resp.Body.Close()) }()

// Get the updated debug state to check if the worker was added
updatedDebugState := getDebugState(t, tester)
Expand Down
8 changes: 4 additions & 4 deletions caddy/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type FrankenPHPApp struct {
logger *slog.Logger
}

var iniError = errors.New(`"php_ini" must be in the format: php_ini "<key>" "<value>"`)
var errIni = errors.New(`"php_ini" must be in the format: php_ini "<key>" "<value>"`)

// CaddyModule returns the Caddy module information.
func (f FrankenPHPApp) CaddyModule() caddy.ModuleInfo {
Expand Down Expand Up @@ -274,14 +274,14 @@ func (f *FrankenPHPApp) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
parseIniLine := func(d *caddyfile.Dispenser) error {
key := d.Val()
if !d.NextArg() {
return d.WrapErr(iniError)
return d.WrapErr(errIni)
}
if f.PhpIni == nil {
f.PhpIni = make(map[string]string)
}
f.PhpIni[key] = d.Val()
if d.NextArg() {
return d.WrapErr(iniError)
return d.WrapErr(errIni)
}

return nil
Expand All @@ -298,7 +298,7 @@ func (f *FrankenPHPApp) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {

if !isBlock {
if !d.NextArg() {
return d.WrapErr(iniError)
return d.WrapErr(errIni)
}
err := parseIniLine(d)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions caddy/mercure.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ func (f *FrankenPHPModule) assignMercureHub(ctx caddy.Context) {
func createMercureRoute() (caddyhttp.Route, error) {
mercurePublisherJwtKey := os.Getenv("MERCURE_PUBLISHER_JWT_KEY")
if mercurePublisherJwtKey == "" {
return caddyhttp.Route{}, errors.New(`The "MERCURE_PUBLISHER_JWT_KEY" environment variable must be set to use the Mercure.rocks hub`)
return caddyhttp.Route{}, errors.New(`the "MERCURE_PUBLISHER_JWT_KEY" environment variable must be set to use the Mercure.rocks hub`)
}

mercureSubscriberJwtKey := os.Getenv("MERCURE_SUBSCRIBER_JWT_KEY")
if mercureSubscriberJwtKey == "" {
return caddyhttp.Route{}, errors.New(`The "MERCURE_SUBSCRIBER_JWT_KEY" environment variable must be set to use the Mercure.rocks hub`)
return caddyhttp.Route{}, errors.New(`the "MERCURE_SUBSCRIBER_JWT_KEY" environment variable must be set to use the Mercure.rocks hub`)
}

mercureRoute := caddyhttp.Route{
Expand Down
Loading