rest e front end

Post on 06-Aug-2015

93 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Arquitetura REST &

Front-End

SimplesDental

SimplesDental

10Mil+Clinicas cadastradas

1Mil+Clinicas ativas todos os dias

Luiz H. Estácio

Lucas Carlessi

luizstacioluiz@simplesdental.com

lucascarlessilucas@simplesdental.com

O que é REST?

• Client-Server

• Stateless

• Cache

• Layered System

• Uniform Interface

REST

Client-Server

Stateless

Cache

Layered System

Uniform Interface• Identificação de recursos

• Representações de recursos

• Respostas auto-explicativas

• Hypermedia

URI

Cada recurso deve possuir uma URI específica e coesa.

Uma aplicação RESTful trata os verbos de uma requisição, tornando uma URI mais expressiva.

URI - Verbos

POST, GET, PUT, DELETE, OPTIONS e HEAD

OPTIONS

Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept, Referer, User-Agent, X-AUTH-TOKEN Access-Control-Allow-Methods:POST, GET, PUT, DELETE, OPTIONS Access-Control-Allow-Origin:* Allow:* Content-Length:0

OPTIONS http://app.simplesdental.com/pacientes

URI

Response

POST

{ "id": “1234",

"nome": “Luiz Henrique Estácio”, “telefones”: ["489911499"]

}

POST http://app.simplesdental.com/pacientes {

"nome": “Luiz Henrique Estácio”, “telefones”: ["489911499"]

}

URI

Response

GET

[ { "id": “1233",

"nome": "Lucas Carlessi", “telefones”: ["489900000"]

}, { "id": “1234",

"nome": “Luiz Henrique Estácio”, “telefones”: ["489911499"]

} ]

GET http://app.simplesdental.com/pacientesURI

Response

GET

{ "id": “1234", "nome": “Luiz Henrique Estácio”, “telefones”: [“489911499”]

}

GET http://app.simplesdental.com/pacientes/1234URI

Response

PUT

{ "id": “1234",

"nome": “Luiz Henrique Estácio Cândido”, “telefones”: ["489911499"]

}

PUT http://app.simplesdental.com/pacientes/1234 {

"nome": “Luiz Henrique Estácio Cândido” }

URI

Response

DELETE

Status Code: 200 OK

DELETE http://app.simplesdental.com/pacientes/123

URI

Response

Common Status Codes• 200 - Success

• 400 - Bad Request

• 401 - Unauthorized

• 404 - Not found

Richardson Maturity Model

RESTful

O que precisamos conhecer?

Documentação

SPA

SPA?

Single Page Application

GET https://api.simplesdental.com/recebimentos

GET https://api.simplesdental.com/recebimentos/122

PUT https://api.simplesdental.com/recebimentos/122

PUT https://api.simplesdental.com/recebimentos/123/pagar

POST https://api.simplesdental.com/recebimentos

Spring-Data JPA

Jackson JSON Jackson Datatype Hibernate

SimplesDental

top related