func Respond(to *textoutput.TextOutput, b []byte, sourceFilename, handlerName, status, msg, method, path string) []byte {
	thread := &starlark.Thread{Name: "a thread"}
	globals, err := starlark.ExecFile(thread, sourceFilename, nil, nil)
	if err != nil {
		to.Err("error: " + err.Error())
		return []byte{}
	}
	handlerFunc, ok := globals[handlerName]
	if !ok {
		to.Err("error: could not find function " + to.LightBlue(handlerName) + " in " + to.LightGreen(sourceFilename))
		return []byte{}
	}
	datestring := time.Now().Format("Mon, 02 Jan 2006 15:04:05 GMT")
	v, err := starlark.Call(thread, handlerFunc, starlark.Tuple{starlark.String(status), starlark.String(msg), starlark.String(method), starlark.String(path), starlark.String(datestring)}, nil)
	if err != nil {
		to.Err("error: " + err.Error())
		return []byte{}
	}
	starString, ok := v.(starlark.String)
	if !ok {
		to.Err("error: " + to.LightBlue(handlerName) + " in " + to.LightGreen(sourceFilename) + " returned something that was not a string")
		return []byte{}
	}
	//log.Println("returning " + starString.GoString())
	return []byte(starString.GoString())
}
// Respond will append a valid HTTP response to the provide bytes.
// The status param should be the code plus text such as "200 OK".
Respond will append a valid HTTP response to the provide bytes.
The status param should be the code plus text such as "200 OK".
// Respond will append a valid HTTP response to the provide bytes . // The status param should be the code plus text such as " 200 OK " .
func Respond(to *textoutput.TextOutput, b []byte, sourceFilename, handlerName, status, msg, method, path string) []byte {
	thread := &starlark.Thread{Name: "a thread"}
	globals, err := starlark.ExecFile(thread, sourceFilename, nil, nil)
	if err != nil {
		to.Err("error: " + err.Error())
		return []byte{}
	}
	handlerFunc, ok := globals[handlerName]
	if !ok {
		to.Err("error: could not find function " + to.LightBlue(handlerName) + " in " + to.LightGreen(sourceFilename))
		return []byte{}
	}
	datestring := time.Now().Format("Mon, 02 Jan 2006 15:04:05 GMT")
	v, err := starlark.Call(thread, handlerFunc, starlark.Tuple{starlark.String(status), starlark.String(msg), starlark.String(method), starlark.String(path), starlark.String(datestring)}, nil)
	if err != nil {
		to.Err("error: " + err.Error())
		return []byte{}
	}
	starString, ok := v.(starlark.String)
	if !ok {
		to.Err("error: " + to.LightBlue(handlerName) + " in " + to.LightGreen(sourceFilename) + " returned something that was not a string")
		return []byte{}
	}
	return []byte(starString.GoString())
}
func Respond ( to * textoutput . TextOutput , b [ ] byte , sourceFilename , handlerName , status , msg , method , path string ) [ ] byte { thread := & starlark . Thread { Name : " " } globals , err := starlark . ExecFile ( thread , sourceFilename , nil , nil ) if err != nil { to . Err ( " " + err . Error ( ) ) return [ ] byte { } } handlerFunc , ok := globals [ handlerName ] if ! ok { to . Err ( " " + to . LightBlue ( handlerName ) + " " + to . LightGreen ( sourceFilename ) ) return [ ] byte { } } datestring := time . Now ( ) . Format ( " " ) v , err := starlark . Call ( thread , handlerFunc , starlark . Tuple { starlark . String ( status ) , starlark . String ( msg ) , starlark . String ( method ) , starlark . String ( path ) , starlark . String ( datestring ) } , nil ) if err != nil { to . Err ( " " + err . Error ( ) ) return [ ] byte { } } starString , ok := v . ( starlark . String ) if ! ok { to . Err ( " " + to . LightBlue ( handlerName ) + " " + to . LightGreen ( sourceFilename ) + " " ) return [ ] byte { } } return [ ] byte ( starString . GoString ( ) ) }
Respond will append a valid HTTP response to the provide bytes.
Respond will append a valid HTTP response to the provide bytes .
//log.Println("returning " + starString.GoString())