This commit is contained in:
Sameer Dev 2024-04-23 16:04:49 +05:30
parent 27d720ebad
commit 7bf8186c3d
2 changed files with 34 additions and 0 deletions

13
fc.toml Normal file
View File

@ -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"

21
handler.go Normal file
View File

@ -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)
}