16
16
*/
17
17
class CloudFunctions {
18
18
19
- private static stdClass $ response ;
20
-
21
- /** */
19
+ /** On HTTPS */
22
20
public static function on_https ( ServerRequestInterface $ request ): ResponseInterface {
23
21
$ params = $ request ->getQueryParams ();
24
22
$ body = sprintf ('Hello, %s! ' , $ params ['name ' ] ?? 'World ' );
@@ -27,7 +25,7 @@ public static function on_https( ServerRequestInterface $request ): ResponseInte
27
25
->withStatus (200 );
28
26
}
29
27
30
- /** */
28
+ /** On Pub/Sub Event */
31
29
public static function on_pubsub ( CloudEventInterface $ event ): void {
32
30
$ log = fopen (getenv ('LOGGER_OUTPUT ' ) ?: 'php://stdout ' , 'wb ' );
33
31
$ cloudEventData = $ event ->getData ();
@@ -36,15 +34,15 @@ public static function on_pubsub( CloudEventInterface $event ): void {
36
34
fwrite ($ log , "Hello, $ name! " . PHP_EOL );
37
35
}
38
36
39
- /** */
37
+ /** On GCS Event */
40
38
public static function on_gcs ( CloudEventInterface $ event ): void {
41
39
$ log = fopen (getenv ('LOGGER_OUTPUT ' ) ?: 'php://stdout ' , 'wb ' );
42
40
$ data = $ event ->getData ();
43
- fwrite ($ log , 'Event: ' . $ event ->getId () . PHP_EOL );
41
+ fwrite ($ log , 'Event: ' . $ event ->getId () . PHP_EOL );
44
42
fwrite ($ log , 'Event Type: ' . $ event ->getType () . PHP_EOL );
45
- fwrite ($ log , 'Bucket: ' . $ data ['bucket ' ] . PHP_EOL );
46
- fwrite ($ log , 'File: ' . $ data ['name ' ] . PHP_EOL );
47
- fwrite ($ log , 'Metageneration : ' . $ data ['metageneration ' ] . PHP_EOL );
43
+ fwrite ($ log , 'Bucket: ' . $ data ['bucket ' ] . PHP_EOL );
44
+ fwrite ($ log , 'File: ' . $ data ['name ' ] . PHP_EOL );
45
+ fwrite ($ log , 'Metagen : ' . $ data ['metageneration ' ] . PHP_EOL );
48
46
fwrite ($ log , 'Created: ' . $ data ['timeCreated ' ] . PHP_EOL );
49
47
fwrite ($ log , 'Updated: ' . $ data ['updated ' ] . PHP_EOL );
50
48
}
0 commit comments