• 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
FroMage / ceylon.net
Ceylon Network Platform Module
Description

This module defines APIs for:

  • representing and manipulating URIs,
  • connecting to HTTP servers, and
  • defining HTTP endpoints and executing HTTP servers.

The ceylon.net.uri::Uri class supports connection to an HTTP URI. A new Uri may be obtained using ceylon.net.uri::parse.

void getit(String uriAsString) {
    Uri uri = parse(uriAsString);
    Request request = uri.get();
    Response response = request.execute();
    print(response.contents);
}

A ceylon.net.http.server::Server represents a HTTP server. A new Server may be defined using ceylon.net.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));
}
Category SDK

The Ceylon SDK

Last Published Mar 11, 2016
Stats Downloads (JVM): 23456
Downloads (JS): 0
Source downloads: 13042
Module links Home
Code repository
Issue tracker
Imported By
Browse
List of published versions
1.2.2 JVM JVM: 1.2.x, 1.3.x (latest) Published Mar 11, 2016 Browse
View docs
1.2.1 JVM JVM: 1.2.x, 1.3.x (latest) Published Feb 11, 2016 Browse
View docs
1.2.0-3 JVM JVM: 1.2.x, 1.3.x (latest) Published Nov 30, 2015 Browse
View docs
1.2.0-2 JVM JVM: 1.2.x, 1.3.x (latest) Published Nov 6, 2015 Browse
View docs
1.2.0-1 JVM JVM: 1.2.x, 1.3.x (latest) Published Nov 3, 2015 Browse
View docs
1.2.0 JVM JVM: 1.2.x, 1.3.x (latest) Published Oct 28, 2015 Browse
View docs
1.1.0 JVM JVM: 1.1.0 (outdated) Published Oct 8, 2014 Browse
View docs
1.0.1 JVM JVM: 1.0.0 (outdated) Published Dec 1, 2013 Browse
View docs
1.0.0 JVM JVM: 1.0.0 (outdated) Published Nov 11, 2013 Browse
View docs
0.6.1 JVM JVM: M6 (outdated) Published Sep 24, 2013 Browse
View docs
0.6 JVM JVM: M6 (outdated) Published Sep 20, 2013 Browse
View docs
0.5.3 JVM JVM: M5 (outdated) Published Apr 24, 2013 Browse
View docs
0.5.2 JVM JVM: M5 (outdated) Published Apr 18, 2013 Browse
View docs
0.5.1 JVM JVM: M5 (outdated) Published Mar 20, 2013 Browse
View docs
0.5 JVM JVM: M5 (outdated) Published Mar 14, 2013 Browse
View docs
0.4 JVM JVM: M4 (oudated) Published Oct 29, 2012 Browse
View docs
0.3.2 JVM JVM: M3.1 (outdated) Published Aug 3, 2012 Browse
View docs
0.3.1 JVM JVM: M3.1 (outdated) Published Jul 6, 2012 Browse
View docs
lucaswerkmeister commented Oct 23, 2016

NOTE: In the Ceylon 1.3.0 release, ceylon.net was split up into ceylon.http.common, ceylon.http.client, ceylon.http.server, and ceylon.uri.

You must be logged in to comment.

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