Re-implemented response handling using dispatcher pattern

Also updated examples to use new API with ok() and error() functions