All Projects → StevenKin → Mineserver

StevenKin / Mineserver

🚗 http server implementation for java native nio api

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Mineserver

T Io
解决其它网络框架没有解决的用户痛点,让天下没有难开发的网络程序
Stars: ✭ 1,331 (+643.58%)
Mutual labels:  nio, http-server
LightWebServer
Java web server using NIO, compatible with http1.1 and support simple MVC function.
Stars: ✭ 38 (-78.77%)
Mutual labels:  nio, http-server
Lotos
tiny but high-performance HTTP Server
Stars: ✭ 140 (-21.79%)
Mutual labels:  http-server
Marvin
A go-kit HTTP server for the App Engine Standard Environment
Stars: ✭ 164 (-8.38%)
Mutual labels:  http-server
Pulsar
Event driven concurrent framework for Python
Stars: ✭ 1,867 (+943.02%)
Mutual labels:  http-server
Httpp
Micro http server and client written in C++
Stars: ✭ 144 (-19.55%)
Mutual labels:  http-server
Nasus
Zero-configuration command-line async HTTP files server in Clojure. Like Python's SimpleHTTPServer but scalable.
Stars: ✭ 158 (-11.73%)
Mutual labels:  http-server
Pure Http
✨ The simple web framework for Node.js with zero dependencies.
Stars: ✭ 139 (-22.35%)
Mutual labels:  http-server
Rayo.js
Micro framework for Node.js
Stars: ✭ 170 (-5.03%)
Mutual labels:  http-server
Nettychat
基于Netty+TCP+Protobuf实现的Android IM库,包含Protobuf序列化、TCP拆包与粘包、长连接握手认证、心跳机制、断线重连机制、消息重发机制、读写超时机制、离线消息、线程池等功能。
Stars: ✭ 1,979 (+1005.59%)
Mutual labels:  nio
Simplenet
An easy-to-use, event-driven, asynchronous network application framework compiled with Java 11.
Stars: ✭ 164 (-8.38%)
Mutual labels:  nio
N00brat
Remote Administration Toolkit (or Trojan) for POSiX (Linux/Unix) system working as a Web Service
Stars: ✭ 148 (-17.32%)
Mutual labels:  http-server
Typed Schema
Typelevel http service definition DSL
Stars: ✭ 145 (-18.99%)
Mutual labels:  http-server
Tesla
Tesla is a gateway service that provides dynamic routing,waf,support spring cloud,gRPC,DUBBO and more.
Stars: ✭ 161 (-10.06%)
Mutual labels:  http-server
Autocser
AutoCSer is a high-performance RPC framework. AutoCSer 是一个以高效率为目标向导的整体开发框架。主要包括 TCP 接口服务框架、TCP 函数服务框架、远程表达式链组件、前后端一体 WEB 视图框架、ORM 内存索引缓存框架、日志流内存数据库缓存组件、消息队列组件、二进制 / JSON / XML 数据序列化 等一系列无缝集成的高性能组件。
Stars: ✭ 140 (-21.79%)
Mutual labels:  http-server
Libhv
🔥 比libevent、libuv更易用的国产网络库。A c/c++ network library for developing TCP/UDP/SSL/HTTP/WebSocket client/server.
Stars: ✭ 3,355 (+1774.3%)
Mutual labels:  http-server
Pohjavirta
Fast & Non-blocking Clojure wrapper for Undertow
Stars: ✭ 139 (-22.35%)
Mutual labels:  http-server
Carmelo
Carmelo is a fast, scalable Java server framework designed for online games. It uses Netty and Fastjson for highly efficient network transmission and supports both TCP/HTTP protocols.
Stars: ✭ 148 (-17.32%)
Mutual labels:  nio
Vert.x
Vert.x is a tool-kit for building reactive applications on the JVM
Stars: ✭ 12,544 (+6907.82%)
Mutual labels:  nio
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (-1.68%)
Mutual labels:  http-server

MineServer

一个基于原生的nio实现的httpserver。

目前实现的功能

  • get/post方法
  • 静态文件传输
  • http 参数传递,支持url和请求体两种方式
  • 支持长链接,暂不支持http pipeline
  • 支持部分请求/响应头
  • 支持cookie
  • 支持session
  • 支持用户实现HttpHandle接口,通过Controller注解产生动态web内容

如何使用

  • 项目用maven构建,请确保已安装maven,然后使用下面命令。
1. git clone [email protected]:StevenKin/MineServer.git
2. git clone [email protected]:StevenKin/Boomvc.git
3. cd MineServer & mvn clean install
4. cd Boomvc/boomvc-ioc & mvn clean install
  • 加入依赖和配置到pom.xml
<dependency>
        <groupId>me.stevenkin.http</groupId>
        <artifactId>mineserver-core</artifactId>
        <version>0.1</version>
</dependency>
  • 写一个controller控制器
@Controller(method = HttpParser.METHOD.GET,urlPatten = "/get",initParameters = {
        @InitParameter(key="key1",value="value1"),
        @InitParameter(key="key2",value="value2")
})
public class TestController extends AbstractHandle {

    @Override
    public void service(HttpRequest httpRequest, HttpResponse httpResponse) throws Exception {
        Map<String,String> params = httpRequest.getParams();
        for(Map.Entry<String,String> entry : params.entrySet()){
            System.out.println(entry.getKey()+":"+entry.getValue());
        }
        System.out.println();
        Iterator<String> iterator = getInitParameterNames();
        while(iterator.hasNext()){
            String key = iterator.next();
            System.out.println(key+":"+getInitParameter(key));
        }
        char[] chars = {'h','e','l','l','o',',','w','o','r','l','d'};
        Writer writer = httpResponse.getWrite();
        writer.write(chars);
        writer.flush();
    }
}

这个控制器就可以输出helloworld啦...

  • 然后我们要写一个配置文件app.properties
server = MineServer
port = 8080
showDir = true
basePath = D:/workspace/
host = localhost
coreThreadCount = 10

配置很简单,我来解释一下配置的意思

server : 服务器名,是服务器监听的端口
port : 服务器监听的端口
showDir : 访问静态文件时如果是目录是否显示
basePath : 静态路径映射的基目录
host : 主机名
coreThreadCount : 处理请求的线程池大小
  • 写一个Main类来启动应用
public class MineApplication {

    public static void main(String[] args){
        MineServer.run(MineApplication.class, args);
    }

}
  • 如何运行?添加下面配置到pom.xml
<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>me.stevenkin.mineapp.MineApplication</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id> <!-- this is used for inheritance merges -->
                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

使用命令mvn clean package打出jar包,然后Java -jar app.jar就可以运行了,也可以到MineServer/example里看写好的示例。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].