mirror of
https://github.com/hanzoai/functions.git
synced 2026-10-30 15:04:37 +00:00
hello.go is a fission function, not a program: package main with a Handler and no main. It is uploaded to the builder image by `fission package create --src` and compiled there, never by this module. Sitting in a normal package it broke `go build ./...` with "function main is undeclared in the main package". testdata is the directory Go ignores, so the file still ships to the builder byte-for-byte while leaving the module build alone. Co-authored-by: Hanzo Dev <[email protected]>
21 lines
382 B
Go
21 lines
382 B
Go
package main
|
|
|
|
import (
|
|
"io"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
// Handler is the entry point for this fission function
|
|
func Handler(w http.ResponseWriter, r *http.Request) { //nolint:golint,unused,deadcode
|
|
bytes, err := io.ReadAll(r.Body)
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
_, err = w.Write(bytes)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|