middleware for leonard project