background preloader

REST

Facebook Twitter

CORS

CXF. REST Tip: Deep etags give you more benefits. ETags, or entity-tags, are an important part of HTTP, being a critical part of caching, and also used in "conditional" requests. So what is an etag? Entity tag The ETag response-header field value, an entity tag, provides for an "opaque" cache validator. That's not very helpful, is it? The easiest way to think of an etag is as an MD5 or SHA1 hash of all the bytes in a representation. Aside: I am only talking about strong etags here. ETags are returned in a response to a GET: joe@joe-laptop:~$ curl --include HTTP/1.1 200 Ok Date: Wed, 21 Mar 2007 15:06:15 GMT Server: Apache etag: "078de59b16c27119c670e63fa53e5b51" Content-Length: 23081 Vary: Accept-Encoding,User-Agent Connection: close Content-Type: application/xhtml+xml; charset=utf-8 <!

That's a great savings in bandwidth. The inclusion of an If-* header turns any normal request into a "conditional" request, in this case our GET became a "conditional" GET. Static files Why not turn them all on? Non-static content. FasterXML/jackson-core. HATEOAS 101: An Opinionated Introduction. REST Tip: Deep etags give you more benefits.

Client Side Caching

How to GET a Cup of Coffee. HATEOAS by Example « Zienit. Hypermedia as the Engine of Application State (HATEOAS) is a very useful concept in the RESTful architectural style. The best way to show the benefits of HATEOAS is by giving an example. In this post I’ll be using the Jersey JAX-RS framework to build three RESTFul services. By mixing XForms into the equation, these services form a complete (yet tiny) web application. The example can be deployed on GlassFish.

The RESTFul resources and their representations There are three resources that make up my example. The first resource is a list of customers and will be represented as pure XML data. In this example, there is a link to the next chunk of customers (at lines 23-25), but there is no link to the previous chunk, because there is none. The second resource is a single customer. The third resource is a XHTML+XForms form through which a list of customers can be edited (for simplicities sake, “editing” here means browsing forwards and backwards through the list. JAXB classes Test data. Hateoas — Scott Banwart's Blog. Presentation: From REST to HATEOAS. This week in REST. What is statelessness in REST ? - In my post Fomenting unREST : Is RESTfulness a semantics game ? Why does REST require statelessness ? , I had commented on some of my thoughts on dealing with some of the constraints prescribed by REST one of them being statelessness. Some of those thoughts continued to churn in my mind, and I had a few helpful interactions along the way which led me to what I believe to be the "Aha moment" on statelessness in REST.

That doesn't mean I'm necessarily right, feel free to comment on my thoughts in case you believe any differently or have a nuanced opinion. Background Per section 3.4.3 of Roy Fielding's dissertation The client-stateless-server style derives from client-server with the additional constraint that no session state is allowed on the server component. The same thought is further commented upon in section 5.1.3. The potential confusion areas Given the clear prohibition of storing client state on server, there are some typical idioms which do get challenged as REST unfriendly. eg. Java - RESTful Authentication via Spring. OAuth Explained and What It Is Good For.

Twitter recently announced OAuth support and that eventually they will be deprecating HTTP Basic Authentication in favor of OAuth. Knowing this, I figured it was about time to get familiar with OAuth and update the Twitter gem to use it. Let me start by explaining my history with OAuth. I have none. There that was fast. I didn’t read the specifications or any articles on OAuth. I simply dove in code first and tried to figure out what was going on and how to make things work. For the code examples below, I’ll be using the OAuth gem. Sudo gem install oauth Tokens and Secrets At first, the hardest thing to figure out was all the tokens and secrets.

The consumer token and secret are provided for you by the OAuth provider, when you register an application with them. Consumer = OAuth::Consumer.new( 'consumer token', 'consumer secret', {:site => ' ) Before I go on, let me explain the end goal. Request Token request_token.authorize_url Access Token The Twitter Gem. Basic and Digest authentication for a RESTful Service with Spring Security 3.1 | baeldung. Last Update: 14.04.2013 (3rd update) Table of Contents 1. Overview This article discusses how to set up both Basic and Digest Authentication on the same URI structure of a REST API. In a previous article, we discussed another method of securing the REST Service – form based authentication, so Basic and Digest authentication is the natural alternative, as well as the more RESTful one. 2. The main reason that form based authentication is not ideal for a RESTful Service is that Spring Security will make use of Sessions – this is of course state on the server, so the statelessness constraints in REST is practically ignored.

We’ll start by setting up Basic Authentication – first we remove the old custom entry point and filter from the main <http> security element: Note how support for basic authentication has been added with a single configuration line – <http-basic /> – which handles the creation and wiring of both the BasicAuthenticationFilter and the BasicAuthenticationEntryPoint. 2.1. 3. 4. Blog Archive » Testing RESTful Web Services made easy using the REST-assured Framework. There are many frameworks out there to facilitate testing RESTful webservices but there is one framework I’d like to acquaint you with my favourite framework named REST-assured. REST-assured offers a bunch of nice features like a DSL-like syntax, XPath-Validation, Specification Reuse, easy file uploads and those features we’re going to explore in the following article.

With a few lines of code and Jersey I have written a RESTful web service that allows us to explore the features of the REST-assured framework and to run tests against this service. Prerequisites We’re going to need a JDK and Maven .. nothing more … The REST Service to be tested I have added a demo web application that exposes a RESTful service (Jersey used here) and allows us to run our tests against it. There are two possible ways to run the web app: Check out the tutorial sources (see chapter “ Tutorial Sources Download “) and run REST Service Overview Adding REST-assured to your Maven project Examples Verify JSON GET Request.