Rest API with Java

2020/03/13 Java

Rest Web Services

  • JAX-RS(Java API for RESTful Web Services) defined in JSR311. JAX-RS只是一套接口规范,位于javax.ws.rs. 包含了很多Java annotation的定义
  • JAX-RS 具体实现由第三方提供,比如Sun的Jersy. 实现包含javax.ws.rs.*, 所以不用额外提供JAX-RS

Idempotence

Reportable or not.

  • GET clearly is.
  • DELETE is.
  • PUT is. PUT /messages/42 update message 42
  • POST is NOT.

Response Header: Content Type

  • Directives
    • dedia-type: the MIME type of the resource or the data
    • charset
    • boundary

HATEOAS(Hypermedia as the Engine of Application State)

  • REST dont have service definitions/documentations
  • All you need to nevigate a REST API are within the response itself

Search

    Table of Contents