Client
server
Verb: HTTP/GET
Url: '/'
authorization: user@example.com
Well known entry point:
verb: HTTP/GET
url: '/'
Content-type: 'application/root'
Body:
{
Links:
[
{
Rel: "CreateUser",
Href: "/Users",
Meta: { Name: "Sample name" }
}
]
}
User doesn't exist
Verb: HTTP/POST
Url: '/users'
authorization: user@example.com
Content-type: application/json
body:
{ Name: 'Jane Doe' }
creates/updates user
Content-type: 'application/user'
{
Name: "Jane Doe",
Links:
[
{
Rel: "UpdateUser",
Href: "/Users"
Meta: { Name: "Sample name" }
},
{
Rel: "GetBlogsPosts",
Href: "/Blogs"
}
]
}
Verb: HTTP/GET
Url: '/Blogs'
authorization: user@example.com
get blog posts for user
Content-type: 'application/blogs'
{
Items:
[
],
Links:
[
{
Rel: "AddBlogPost",
Href: "/Blogs/Add",
Meta: { Title: "Sample", Body: "Sample" }
}
]
}
Verb: HTTP/POST
Url: '/blogs/add'
authorization: user@example.com
Content-type: application/json
body:
{ Title: "Restful Architectures", Body: "Hello World" }
add blog to user's account
Content-type: 'application/blogs'
{
Items:
[
{
Title: "Restful Architectures",
Links:
[
{
Rel: "Delete",
Href: "/Blogs/Delete/1",
},
{
Rel: "Detail",
Href: "/Blogs/Detail/1"
},
{
Rel: "Update",
Href: "/Blogs/Update/1",
Meta: { Title: "Sample", Body: "Sample" }
}
]
}
],
Links:
[
{
Rel: "AddBlogPost",
Href: "/Blogs/Add",
Meta: { Title: "Sample", Body: "Sample" }
}
]
}
return the blog's detail
Content-type: 'application/blog'
{
Title: "Restful Architectures",
Body: "Hello World",
Links:
[
{
Rel: "Delete",
Href: "/Blogs/Delete/1",
},
{
Rel: "Update",
Href: "/Blogs/Update/1",
Meta: { Title: "Sample", Body: "Sample" }
},
{
Rel: "GetBlogsPosts",
Href: "/Blogs"
}
]
}
Verb: HTTP/GET
Url: '/Blogs/Detail/1'
authorization: user@example.com
Rest Like The Best*
Amir Rajan
Improving Enterprises
www.amirrajan.net
@amirrajan
Why Rest?
what's Rest?
Rpc relates to REST
as
Soap relates to ???
Hypermedia Control
The links tell me where I can go, and will only point to valid transitions
the "works for me" protocol
Uniform Interface:
everything comes back with a content-type that maps to an application type
everything has a "links" collection (if there are any valid ones)
well known entry points to the application
root: "/" (definitley)
Maybe some other ones: eg: "/blogs/{id}"
application/json
json is awesome, and that's what you'll get back,
...alternately you can use xml...
I dont use HTTP/PUTS cause they make my head hurt
Posts can save or update...I'm just going to leave it
at that and not make my consumers guess
Let's create a blog service!