added middleware methods for afterPostApiSession and afterGetApiSession