Skip to content
/ Glade Public

A web server with an event-driven and modular design

License

Notifications You must be signed in to change notification settings

srikavin/Glade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Glade Run Tests codecov

An extensible and event-driven web server written with Java 11.

Features

  • Automatic conversion to/from Objects in HTTP requests and responses
  • Fast response times with minimal overhead
  • Websocket support

Usage

Glade uses JitPack.io as a package repository. To add Glade to a Maven or Gradle project use the following details:

Maven

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
	<dependency>
	    <groupId>com.github.srikavin</groupId>
	    <artifactId>Glade</artifactId>
	    <version>master-SNAPSHOT</version>
	</dependency>
</dependencies>

Gradle

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
        implementation 'com.github.srikavin:Glade:master-SNAPSHOT'
}

Quick Start

import me.infuzion.web.server.EventListener;
import me.infuzion.web.server.Server;
import me.infuzion.web.server.event.EventManager;
import me.infuzion.web.server.event.def.PageRequestEvent;
import me.infuzion.web.server.event.reflect.EventHandler;
import me.infuzion.web.server.event.reflect.Route;
import me.infuzion.web.server.event.reflect.param.mapper.impl.QueryParam;
import me.infuzion.web.server.event.reflect.param.mapper.impl.Response;

import java.io.IOException;
import java.net.InetSocketAddress;

class Example {
    public static void main(String[] args) throws IOException {
        // Creates a server that listens to port 8971 on all interfaces
        Server server = new Server(new InetSocketAddress("0.0.0.0", 8971));

        EventManager manager = server.getEventManager();

        // Registers an event listener that responds to all incoming requests
        // Visiting '0.0.0.0:8971/?name=World' will display 'Hello, World' in a web browser
        manager.registerListener(new EventListener() {
            @EventHandler
            @Route("/")
            @Response("text/plain")
            public String handler(PageRequestEvent e, @QueryParam("name") String name) {
                return "Hello, " + name;
            }
        });

        // Starts the server (Note that this blocks while the server is running)
        server.start();
    }
}

Contributing

Contributions are welcome! If you notice a bug or have a feature request feel free to open an issue or a pull request.

About

A web server with an event-driven and modular design

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages