Cloud Flashcards
Struktura OCI (6)
OS
docker - virtualni kontejner
kubernetes - orchestrator dockeru
jvm - v kazdem dockeru
java server - automatizace
java kod
Http request - metody (4) + metody pro metadata (2)
get (default)
post (insert)
put (update)
delete
head, options
Http response - statusy (5)
100 - info
200 - success
300 - redirect
400 - client error
500 - server error
Http response syntax pro zpravu “This,is,message” v UTF-8
header + nepovinne body
HTTP/1.1 200 OK
Content-Type: “text/plain; charset=UTF-8”
Content-Length: 123
Date: … GMT
This,is,message
Http request syntax pro www.sample.com/product/1
GET /product/1 HTTP/1.1
Host: www.sample.com
REST co to je, jake muzou byt formaty message
Resource based application; kazdy resource ma svoji entitu s url a operacemi
plain text, json, xml, …
REST handler syntax: nacti parametr “id” a posli zpet message “processing {id}”
Handler handler = (ServerRequest req, ServerResponse res) -> {
String id = req.path().param(“id”);
res.status(Http.Status.OK_200);
res.headers().put(“Content-Type”, “text/plain; charset=UTF-8”);
res.send(“processing “ + id);
};
REST routing syntax pro prirazeni handleru:
“/” - welcome()
“/products” - DELETE - deleteProducts()
Routing routing = Rounting.builder()
.any(“/”, welcome())
.delete(“/products”, deleteProducts())
.build();
REST routing - any - jak zapises lambdou poslani “message”
.any((req, res) -> res.status(200).send(“message”))
REST server configuration pro localhost:8080 syntax
ServerConfiguration config = ServerConfiguration.builder()
.bindAddress(InetAddress.getLocalHost())
.port(8080)
.build();
REST web server - vyrob a spust
WebServer ws = new WebServer(serverConfiguration, routing);
ws.start();