Giter Site home page Giter Site logo

dash's Introduction

dash

High-performance, multithreaded Java HTTP server written using the Netty framework

⚠️ WIP

Dash is currently a work in progress and is not production ready. To access full functionality, you'll also have to depend on Netty since methods in the HttpRequest and HttpResponse class currently directly expose Netty classes. This will change by the time of the first release.

Example

See more

public class Server {
    private final Dash dash;
    private final InetSocketAddress address;
    private final HttpServer server;

    public Server() {
        dash = new Dash();
        address = new InetSocketAddress("localhost", 3000); // bind to localhost:3000
        server = dash.createServer(address); // Create HttpServer
        server.addHandler(new ExampleHandler()); // Add a handler
        listen(); // Start listening for requests
    }

    private void listen() {
        server.listen(future -> {
            if (future.isSuccess()) System.out.printf("Example HTTP server started on %s\n", address);
            else System.out.printf("Failed to start HTTP Server on %s\n", address);
        });
    }
}

class ExampleHandler implements RequestHandler {
    
    @GET(path = "/") // Get requests to "/"
    public void onGetRoot(HttpRequest req, HttpResponse res) {
        res.writeString("Homepage"); // Write string as response
    }
}

dash's People

Contributors

alexsobiek avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.