Skip to content

Instantly share code, notes, and snippets.

@jub0bs
Last active April 23, 2021 19:57
Show Gist options
  • Select an option

  • Save jub0bs/d7f3cfe3a4e0c666af091a20e1e0e8d5 to your computer and use it in GitHub Desktop.

Select an option

Save jub0bs/d7f3cfe3a4e0c666af091a20e1e0e8d5 to your computer and use it in GitHub Desktop.
The executed function of a Google Cloud Function can be a method on a custom type (Srv.Handle, here), under the condition that both the type and method be exported.
package p
import (
"fmt"
"net/http"
)
var Srv = Server{}
type Server struct{}
func (*Server) Handle(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
fmt.Fprint(w, "Hello, World!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment