add attr middleware