GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  JIFTY::MANUAL::TUTORIALREST (3)

.ds Aq ’

NAME

Jifty::Manual::TutorialRest - Web Services

CONTENTS

DESCRIPTION

This builds on Jifty::Manual::Tutorial, so make sure you have a running jifty that roughly resembles the step-by-step from there.

SETUP

You must add this to your site_config.yml



  framework:
    Plugins:
      - REST: {}



See Jifty::Plugin::REST.

The commands assume that you have LWP installed with the GET alias. If not, you’ll need to use the longhand lwp-request -m GET, or curl, or your browser.

help

Make sure it is working:



  $ GET http://localhost:8888/=/help

  Accessing resources:
  ...



You should see some text describing the services, not html (that’s longhand for 404.) Check the config and restart the server.

GET

Just list the models.



  $ GET http://localhost:8888/=/model.yml
  ---
  - MyWeblog.Model.Post



List the Post schema.



  $ GET http://localhost:8888/=/model/Post.yml
  ---
  body:
    label: Content
    name: body
    readable: 1
    sort_order: 1
    type: text
    writable: 1
  id:
    mandatory: 1
    name: id
    readable: 1
    type: serial
    writable: 0
  title:
    default: Untitled post
    label: Title
    name: title
    readable: 1
    sort_order: 0
    type: text
    writable: 1



You did make some posts, right?



  $ GET http://localhost:8888/=/model/Post/id.yml
  ---
  - 1
  - 2



Dump the data:



  $ GET http://localhost:8888/=/model/Post/id/1.yml
  ---
  body: This is my post, the content of which is this, which is mine.
  id: 1
  title: my first post

  $ GET http://localhost:8888/=/model/Post/id/2.yml
  ---
  body: "Content of another post.  Got to go, the cats on fire."
  id: 2
  title: post deux



POST

TODO not working

Actually, it looks like it is not supposed to work this way. Why not?



  $ echo ---
  body: "A post via web services"
  id: 3
  title: "posting from the command-line"
   | lwp-request -m POST http://localhost:8888/=/model/Post.yml
  POST http://localhost:8888/=/model/Post/id/3.yml --> 404 Not Found



PUT

TODO not working



  $ echo ---
  title: "posting from the cli"
   | lwp-request -m PUT http://localhost:8888/=/model/Post/3.yml
  500 Cant read entity body: Connection reset by peer



DELETE



  $  lwp-request -m DELETE http://localhost:8888/=/model/Post/id/3.yml
  ---
  content: {}
  error: ~
  field_errors: {}
  field_warnings: {}
  message: Deleted
  success: 1



Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 JIFTY::MANUAL::TUTORIALREST (3) 2010-09-25

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.