since this middleware is called on every request, perhaps it's worth it to precompile the regexes (including IN_COURSE_WIKI_REGEX). `re.compile` and set them as constants.