using Google.Cloud.Functions.Framework;
using Microsoft.AspNetCore.Http;
using System;
using System.Threading.Tasks;
namespace EnvironmentVariables
{
public class Function : IHttpFunction
{
public async Task HandleAsync(HttpContext context)
{
string foo = Environment.GetEnvironmentVariable("FOO")
?? "Specified environment variable is not set.";
await context.Response.WriteAsync(foo);
}
}
}
// Package tips contains tips for writing Cloud Functions in Go.
package tips
import (
"fmt"
"net/http"
"os"
)
// EnvVar is an example of getting an environment variable in a Go function.
func EnvVar(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "FOO: %q", os.Getenv("FOO"))
}