in funcframework/framework.go [262:277]
func handleTypedReturn(w http.ResponseWriter, funcReturn []reflect.Value) {
if len(funcReturn) == 0 {
return
}
errorVal := funcReturn[len(funcReturn)-1].Interface() // last return must be of type error
if errorVal != nil && reflect.TypeOf(errorVal).AssignableTo(errorType) {
writeHTTPErrorResponse(w, http.StatusInternalServerError, errorStatus, fmtFunctionError(errorVal))
return
}
firstVal := funcReturn[0].Interface()
if !reflect.TypeOf(firstVal).AssignableTo(errorType) {
returnVal, _ := json.Marshal(firstVal)
fmt.Fprintf(w, string(returnVal))
}
}