0

I am new to restler and trying to do the following things, can't seem to get hold of it

I have this class and method exposed via Restler

class Account {
    protected $Api_Version = array('version' => "1.0.2.1234", 'href' => "/");
// Returns the version of the service
// Content-Type: application/vnd.cust.version+json
function version() {
return json_encode($this->version);
}

// Accepts only Content Type: application/vnd.cust.account+json
function postCreate() {

}
}

1) I want to return my own Content-Type to client like in the 'version' method instead of default application/json. In my case its 'application/vnd.cust.version+json'

2) Method postCreate should only accept the request if the Contet-Type is set to 'application/vnd.cust.account+json'. How to check if that header is set in the request.

3) Also in the restler API Explorer, for methond name, how can I show only the method name instead of the 'version.json'. I want to show just 'version' like the method name

Thank you for your help. Narsi

Narsi
  • 1
  • 2

1 Answers1

0

1) maybe Write your own format? Take a Look at http://restler3.luracast.com/examples/_003_multiformat/readme.html

2) you could check the headers and throw Exception on wrong one. Take a Look at this link http://stackoverflow.com/questions/541430/how-do-i-read-any-request-header-in-php

3) have you tried to and the following line to your Index.php?

Resources::$useFormatAsExtension = false

Hope takes you further on :)

CU Inge

Inge
  • 427
  • 7
  • 20