From 7bf8186c3da7c681e8fcb0dcfba1ebea2b77330d Mon Sep 17 00:00:00 2001 From: Sameer Dev Date: Tue, 23 Apr 2024 16:04:49 +0530 Subject: [PATCH] init --- fc.toml | 13 +++++++++++++ handler.go | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 fc.toml create mode 100644 handler.go diff --git a/fc.toml b/fc.toml new file mode 100644 index 0000000..1b9f0e0 --- /dev/null +++ b/fc.toml @@ -0,0 +1,13 @@ +app = "golang-buildpack-func-sample" +region = "asia-south1" +handler = "handler.handler" + +[build] + buildpack_builder = "paketobuildpacks/builder-jammy-base" + buildpacks = ["paketo-buildpacks/go"] + ignorefile = ".gitignore" + [build.args] + foo = "bar" + +[env] + FOO = "BAR" diff --git a/handler.go b/handler.go new file mode 100644 index 0000000..e534133 --- /dev/null +++ b/handler.go @@ -0,0 +1,21 @@ +package main + +// Import necessary packages +import ( + "encoding/json" + "net/http" +) + +// Define the handler function +func handler(context http.ResponseWriter, event *http.Request) { + // Initialize a map to hold the response body + response := map[string]string{ + "message": "Hello, World!", // Set the message to "Hello, World!" + } + + // Set the Content-Type header to application/json + context.Header().Set("Content-Type", "application/json") + + // Encode the response map into JSON and write it to the response + json.NewEncoder(context).Encode(response) +}