adds rpc middleware for server side