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
- Host: GitHub
- URL: https://github.com/linux-china/service-talk-demo
- Owner: linux-china
- Created: 2019-11-06T19:14:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-05T22:38:26.000Z (over 2 years ago)
- Last Synced: 2025-05-14T07:17:08.159Z (about 1 year ago)
- Topics: grpc, http, servicetalk
- Language: Java
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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