Skip to content

How do I use a custom body parser config to handle XML requests?

Notifications You must be signed in to change notification settings

edencorbin/use-xml-body-parser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

use-xml-body-parser

Note: custom body parser config is broken in Sails <= v0.12.1. This example will work with version 0.12.2 onward.

Quick demonstration of overriding the default body parser in Sails (Skipper) to allow parsing XML bodies. All of the relevant code is in the config/http.js file. To test, npm install and sails lift, then use the POST /echo route provided in config/routes.js, e.g.:

curl -H "Content-Type: application/xml" -X POST --data "<root>XML is x-citing</root>" http://localhost:1337/echo

should respond with:

{
  "root": "XML is x-citing"
}

About

How do I use a custom body parser config to handle XML requests?

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.6%
  • CSS 0.4%