Name |
Ceylon Http Server Platform Module |
---|---|
Description |
This module defines APIs for defining HTTP endpoints and executing HTTP servers. A void runServer() { //create a HTTP server value server = newServer { //an endpoint, on the path /hello Endpoint { path = startsWith("/hello"); //handle requests to this path service(Request request, Response response) => response.writeString("hello world"); }, WebSocketEndpoint { path = startsWith("/websocket"); onOpen(WebSocketChannel channel) => print("Channel opened"); onClose(WebSocketChannel channel, CloseReason closeReason) => print("Channel closed"); void onError(WebSocketChannel webSocketChannel, Exception? throwable) {} void onText(WebSocketChannel channel, String text) { print("Received text:"); print(text); channel.sendText(text.uppercased); } void onBinary(WebSocketChannel channel, ByteBuffer binary) { String data = utf8.decode(binary); print("Received binary:"); print(data); value encoded = utf8.encode(data.uppercased); channel.sendBinary(encoded); } } }; //start the server on port 8080 server.start(SocketAddress("127.0.0.1",8080)); } |
Category |
SDK
The Ceylon SDK |
Last Published | Aug 21, 2017 |
Stats |
Downloads (JVM): 12561 Downloads (JS): 0 Source downloads: 1933 |
Module links |
Home Code repository Issue tracker Imported By Browse |
1.3.3 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Aug 21, 2017 |
Browse |
View docs |
|
1.3.2 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Mar 1, 2017 |
Browse |
View docs |
|
1.3.1 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Nov 21, 2016 |
Browse |
View docs |
|
1.3.0 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Sep 15, 2016 |
Browse |
View docs |