HUE-1859 [core] Add generic middleware support