Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vietj/ceylon-vertx
Ceylon API for Vert.x
https://github.com/vietj/ceylon-vertx
Last synced: 30 days ago
JSON representation
Ceylon API for Vert.x
- Host: GitHub
- URL: https://github.com/vietj/ceylon-vertx
- Owner: vietj
- Created: 2013-06-02T18:18:14.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-11-05T21:04:05.000Z (about 8 years ago)
- Last Synced: 2024-10-20T05:03:13.705Z (3 months ago)
- Language: Ceylon
- Size: 535 KB
- Stars: 8
- Watchers: 7
- Forks: 7
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Vert.x over Ceylon
Provides a Ceylon API for the Vert.x framework.
Please see the much improved, official Ceylon.support for Vert.x [here](https://github.com/vert-x3/vertx-lang-ceylon).
# Documentation
Documentation can be found [here](https://modules.ceylon-lang.org/repo/1/io/vertx/ceylon/0.3.10/module-doc/index.html)
# Test Drive
ceylon run vietj.vertx/0.3.10
This will execute the sample [sample](https://github.com/vietj/ceylon-vertx/blob/master/source/vietj/vertx/run.ceylon) server.
# Features
## HTTP
Vertx().createHttpServer().requestHandler(
(HttpServerRequest req) => req.response.contentType("text/html").end("Hello World)
).listen(8080);### HTTP Request
Map headers = req.headers;
Map parameters = req.parameters;
### HTTP Response
req.response.headers("Content-Type" -> "text/html; charset=UTF-8");
or
req.response.contentType("text/html");### RouteMatcher
value router = RouteMatcher();
router.get("/animal/dogs", (HttpServerRequest req) => req.response.end(“You requested dogs"));
router.get("/animal/cats", (HttpServerRequest req) => req.response.end(“You requested cats"));
server.requestHandler(router.handle).listen(8080);## Shared Data
### Shared maps
SharedMap map = vertx.sharedData.getMap("demo.mymap");
map.put("some-key", 123);### Shared sets
SharedSet set = vertx.sharedData.getSet("demo.myset");
set.add("some-value");## Timers
### One shot timers
value timerId = vertx.setTimer(1000, (Integer timerId) => print("And one second later this is printed"));
print("First this is printed");### Periodic timers
value timerId = vertx.setTimer(1000, (Integer timerId) => print("And every second this is printed"));
print("First this is printed");## EventBus
EventBus bus = Vertx().eventBus();
### send/publish
bus.send("foo", "ping");
### Handlers
bus.registerHandler("foo", (Message msg) => msg.reply("pong"));
### Reply handler
bus.send("foo", "ping", (Message msg) => print("Got reply"));
### Event conversion
Now supports String and JSON.
## Uses Promises
Promise promise = bus.registerHandler(...);
promise.onComplete((Registration reg) => print("Registered"), (Exception e) => print("Failed"));