Last active
April 23, 2021 19:57
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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