strongloop / strong-remoting

Communicate between objects in servers, mobile apps, and other servers.
www.strongloop.com
Other
105 stars 93 forks source link

render XML not working #226

Closed yagobski closed 8 years ago

yagobski commented 9 years ago

Hi,

I am using loopback and i want to return xml for some remote methods. I have active xml in config file by editing the variable :

"rest": {
      "normalizeHttpPath": false,
      "xml": true
    },

Returning xml not working is still have json even when i add ?format=xml

in logs i have some warnings like : express deprecated res.send(status): Use res.sendStatus(status) instead node_modules/loopback/node_modules/strong-remoting/lib/http-context.js:426:13

I want to generate sitemap.xml for google. And i am using :

 Tool.sitemap = function (cb) {
        var sm = require('sitemap');
        var options = {
            hostname: xxxxx
            cacheTime: 600000,        // 600 sec - cache purge period
            urls: [
                { url: '/page-1/',  changefreq: 'daily', priority: 0.3 },
                { url: '/page-2/',  changefreq: 'monthly',  priority: 0.7 }            ]
        };
        var sitemap = sm.createSitemap(options);
        sitemap.toXML( function(xml){
            cb(null, xml)
        });

// I have try also to return cb(null, sitemap); and use ?format=xml but not working

    };

    Tool.remoteMethod('sitemap', {
        accepts: [],
        http: {path: '/sitemap', "verb": 'get'},
        returns: {"type": "object", root:true},
        description: "Return sitemap.xml"
    });
richardpringle commented 8 years ago

Hey @yagobski, sorry for the long delay! For future reference I would recommend posting in the LoopBack repository instead.

Did you ever get this figured out or did you move on?

richardpringle commented 8 years ago

Closing this issue. Please re-open and mention me directly in a comment if the issue persists!