An open API service indexing awesome lists of open source software.

https://github.com/linux-china/service-talk-demo

Apple ServiceTalk framework demo
https://github.com/linux-china/service-talk-demo

grpc http servicetalk

Last synced: 3 months ago
JSON representation

Apple ServiceTalk framework demo

Awesome Lists containing this project

README

          

ServiceTalk Demo
================

ServiceTalk: a JVM network application framework with APIs tailored to specific protocols (e.g. HTTP/1.x, HTTP/2.x, etc…​) and supports multiple programming paradigms.

# Http

* Text/Plain

```
responseFactory.ok().payloadBody("Hello World!", textSerializer())
```

* text/html

```
responseFactory.ok().addHeader("Content-Type","text/html").payloadBody(buffer)
```

* JSON

```
HttpSerializationProvider httpSerializationProvider = jsonSerializer(new JacksonSerializationProvider());
HttpSerializer userHttpSerializer = httpSerializationProvider.serializerFor(User.class);

responseFactory.ok().payloadBody(new User(1, "Jackie"), userHttpSerializer)))
```

* Buffer

```
responseFactory.ok().payloadBody(Buffer payloadBody);
```

# gRPC

* Create a proto file under src/main/proto
* Use protobuf-maven-plugin to compile proto files
* Implement logic

# References

* ServiceTalk Docs: https://apple.github.io/servicetalk/servicetalk/SNAPSHOT/
* ServiceTalk Example: https://github.com/apple/servicetalk/tree/master/servicetalk-examples