Refactoring book_data object fetching from request to a middleware for clarity.