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
8 changes: 7 additions & 1 deletion frankenphp.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,12 @@ static void frankenphp_log_message(const char *message, int syslog_type_int) {
go_log((char *)message, syslog_type_int);
}

static char *frankenphp_getenv(const char *name, size_t name_len) {
go_string gname = {name_len, (char *)name};

return go_sapi_getenv(thread_index, &gname);
}

sapi_module_struct frankenphp_sapi_module = {
"frankenphp", /* name */
"FrankenPHP", /* pretty name */
Expand All @@ -765,7 +771,7 @@ sapi_module_struct frankenphp_sapi_module = {
frankenphp_ub_write, /* unbuffered write */
frankenphp_sapi_flush, /* flush */
NULL, /* get uid */
NULL, /* getenv */
frankenphp_getenv, /* getenv */

php_error, /* error handler */

Expand Down
12 changes: 12 additions & 0 deletions frankenphp.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,18 @@ func go_getenv(threadIndex C.uintptr_t, name *C.go_string) (C.bool, *C.go_string
return true, value // Return 1 to indicate success
}

//export go_sapi_getenv
func go_sapi_getenv(threadIndex C.uintptr_t, name *C.go_string) *C.char {
envName := C.GoStringN(name.data, C.int(name.len))

envValue, exists := os.LookupEnv(envName)
if !exists {
return nil
}

return phpThreads[threadIndex].pinCString(envValue)
}

//export go_handle_request
func go_handle_request(threadIndex C.uintptr_t) bool {
select {
Expand Down
Loading