[fix] Move code that depends on resource.http.app inside the callback for resource.http.listen