implement init function of middleware interface