This code is from https://github.com/huge-success/sanic/

It's modified and stripped-down because importing full sanic
increased cold starts.

See https://github.com/fnproject/fdk-python/pull/60 for context.