Add middleware for webapp context management