What does REST stand for?

REST stands for REpresentational State Transfer.

What is a resource?

Anything that can be named is a resource. Usually that nouns that define our model.

What are safe REST operations?

Safe operations are operations that don’t change things. These are: 

  • GET
  • HEAD
  • OPTIONS

What are idempotent operations? Why is idempotency important?

Idempotent operations are operations that always return the same result. Idempotency is important for understanding the limits of effect some operation have on resources. 

Is REST scalable and/or interoperable?

Because of the stateless nature of REST it is easily scalable and due to its HTTP usage it is highly interoperable because many systems support HTTP.

What are the advantages of the RestTemplate?

RestTemplate has methods specific to HTTP methods:

  1. DELETE
  2. GET
  3. HEAD
  4. OPTIONS
  5. POST
  6. PUT

So it is very convenient for REST calls.

Which HTTP methods does REST use?

  1. GET – for read
  2. PUT – for update/replace 
  3. POST – for create
  4. PATCH – for update/modify
  5. DELETE – for delete

What is an HttpMessageConverter?

HttpMessageConverters convert HTTP requests to objects and back from objects to HTTP responses. Spring has a list of converters that is registered by default but it is customizable – additional implementations may be plugged in.

Is REST normally stateless?

REST is stateless because according to its definition it HAS to be stateless; meaning each request must contain all the required information to interact with the server without the server need to store some context between requests. The same can be said about authentication – each request holds the authentication info required for interacting with the server.

What does @RequestMapping do?

@RequestMapping defines handler methods for calls to certain URI. 

Is @Controller a stereotype? Is @RestController a stereotype?

@Controller is a stereotype whilst @RestController is not and is declared in a different package.

What is the difference between @Controller and @RestController?

@Controller result is passed to a view.

@RestController result is processed by a HttpMessageConverter.

For a @Controller to act as a @RestController it has to be combined with @ResponseBody.

When do you need @ResponseBody?

@ResponseBody is required when you want a controller result to me passed to a message converter rather than to a view resolver.

What does @PathVariable do?

@PathVariable gets parameters for a controller method from the URI of the request.

What is the HTTP status return code for a successful DELETE statement?

Direct answer to DELETE may be a 204 No Content or a 202 Accepted (long lasting processing) or 205 Reset Content (DELETE statement was ok but could not be performed). An indirect answer is 200 OK with some response.

What does CRUD mean?

Create Read Update Delete

Is REST secure? What can you do to secure it?

On itself no. Also we can implement some method-level (that is service layer) Spring Security to make it more secure. 

Where do you need @EnableWebMVC?

@EnableWebMvc imports the MVC configuration from WebMvcConfigurationSupport – that in its turn registers HandlerMappings, HandlerAdapters, path matchers etc. + HttpMessageConverters.

Name some common http response codes. When do you need @ResponseStatus?

201,200,204,404 etc.

@ResponseStatus will prevent DispatcherServlet from trying to find a view for the result and will set a status for the response.

For example DELETE methods return just void here  a  @ResponseStatus(HttpStatus.NO_CONTENT) is ok to be put.

Does REST work with transport layer security (TLS)?

Yes.

Do you need Spring MVC in your classpath?

Yes. Spring MVC is the core component for REST support.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.