Write custom handle() function for api.go routes.