mirror of https://github.com/knative/func.git
fix: signature of HTTP go function in template
This commit is contained in:
parent
bcd692be77
commit
bb575b04c0
|
@ -2,12 +2,20 @@ package function
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Handle an HTTP Request.
|
||||
func Handle(ctx context.Context, res http.ResponseWriter, req *http.Request) error {
|
||||
func Handle(ctx context.Context, res http.ResponseWriter, req *http.Request) {
|
||||
|
||||
res.Header().Add("Content-Type", "text/plain")
|
||||
res.Write([]byte("OK\n"))
|
||||
return nil
|
||||
res.Header().Add("Content-Length", "3")
|
||||
res.WriteHeader(200)
|
||||
|
||||
_, err := fmt.Fprintf(res, "OK\n")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error or response write: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,10 @@ func TestHandle(t *testing.T) {
|
|||
|
||||
// Invoke the Handler via a standard Go http.Handler
|
||||
func(w http.ResponseWriter, req *http.Request) {
|
||||
err = Handle(context.Background(), w, req)
|
||||
Handle(context.Background(), w, req)
|
||||
}(w, req)
|
||||
res = w.Result()
|
||||
defer res.Body.Close()
|
||||
|
||||
// Assert postconditions
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue