Nxs constructs - xkp/Doc GitHub Wiki
##Services
Web services will serve information usually not HTML formatted. The client pages will use such information in the way they see fit. Excess provide a simple way to create services:
1- Declare the service in your application's definition file (xml):
<service id="<Your service name>" post="<true|false>" upload_dir="<Where uploaded files will go>"/>
The http method is derived from the post parameter, which defaults to false meaning GET will be used. This same principle applies to pages.
Depending on the chosen http method the parameters will be resolved using the names provided in step 2. This same principle applies to pages.
The exception to the above rule are uploaded files, which will only be available on post requests. To access such files you must access the post property, which at the moment follows the interface of the underlying implementation library (formidable)
var filename = post.files[0].name;
This same principle applies to pages.
2- Implement your service as a traditional xs method in your application code (xs):
method <Your service name>( <Your service parameters> )
{
return <Your service results>;
}
The header and data of xs web services will be derived from the return type of its implementing method. This feature is still fluid in the current implementation and will recognize value data and objects, returning a JSON string to the client.
##Pages