• Modules
    • By category
    • By name
    • Most popular
    • Most downloaded
    • Repository
  • Register
  • Log in
  • Help
    • Start using Ceylon Herd
    • Publish your first module
    • Module publishing guidelines
    • All about Ceylon
    • Keyboard Shortcuts

    • s Focus search module bar
      ? Open this information panel
      j Move selection down
      k Move selection up
      enter Open current selection
Module info
Name
quintesse / ceylon.http.server / 1.3.2
Ceylon Http Server Platform Module
Category SDK

The Ceylon SDK

Backends JVM
Maven coordinates org.ceylon-lang:ceylon.http.server
Compatible Ceylon release JVM: 1.2.x, 1.3.x (latest)
Published Mar 1, 2017
Stats Downloads (JVM): 670
Source downloads: 553
Authors Matej Lazar
Stéphane Épardaud
License Apache Software License
Description

This module defines APIs for defining HTTP endpoints and executing HTTP servers.

A ceylon.http.server::Server represents a HTTP server. A new Server may be defined using ceylon.http.server::newServer.

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));
}
Dependencies
ceylon.collection/1.3.2 shared
ceylon.file/1.3.2
ceylon.http.common/1.3.2 shared
ceylon.interop.java/1.3.2
ceylon.io/1.3.2 shared
ceylon.language/1.3.2
com.redhat.ceylon.module-resolver/1.3.2 shared
io.undertow.core/1.4.4.Final
java.base/7 JDK
org.jboss.xnio.nio/3.3.6.Final
Usage
  • Import
 import ceylon.http.server "1.3.2";
Module links Members
Imported By
Home
Code repository
Issue tracker
Browse
Download .car
No .js archive
Download source archive
Download module documentation
View API documentation

Ceylon Herd v1.24 Copyright 2012-2022 Red Hat. About