Magician-Web

Magician 的官方 Web 组件
授权协议 MIT
开发语言 Java
所属分类 Web应用开发、 WebSocket开发包
软件类型 开源软件
地区 国产
投 递 者 寿伟
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Magician-Web 是Magician的官方 web组件,可以很方便的管理Controller,支持拦截器,会话管理,注解式参数校验,实体类接收参数等

文档

https://magician-io.com

示例

导入依赖

<!-- This is the jar package build by this project -->
<dependency>
    <groupId>com.github.yuyenews</groupId>
    <artifactId>Magician-Web</artifactId>
    <version>last version</version>
</dependency>

<!-- This is Magician -->
<dependency>
    <groupId>com.github.yuyenews</groupId>
    <artifactId>Magician</artifactId>
    <version>last version</version>
</dependency>

<!-- This is the log package, which supports any package that can be bridged with slf4j -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-jdk14</artifactId>
    <version>1.7.12</version>
</dependency>

创建核心handler

@HttpHandler(path="/")
public class DemoHandler implements HttpBaseHandler {

    @Override
    public void request(MagicianRequest magicianRequest, MagicianResponse response) {
        try{
            // 主要是这句
            MagicianWeb.createWeb()
                    .request(magicianRequest);
        } catch (Exception e){
        }
    }
}

创建 Controller

@Route("/demoController")
public class DemoController {

	// You can use entity classes to receive parameters
	@Route(value = "/demo", requestMethod = ReqMethod.POST)
	public DemoVO demo(DemoVO demoVO){
		return demoVO;
	}

	// You can also directly use MagicianRequest to get parameters
	@Route(value = "/demob", requestMethod = ReqMethod.POST)
	public String demob(MagicianRequest request){
		return "ok";
	}

	// Download file
	@Route(value = "/demob", requestMethod = ReqMethod.POST)
	public ResponseInputStream demob(){
		ResponseInputStream responseInputStream = new ResponseInputStream();
		responseInputStream.setName("file name");
		responseInputStream.setBytes(file bytes);
		return responseInputStream;
	}
}

启动 HTTP 服务

Magician.createHttp()
                .scan("handler和controller所在的包名")
                .bind(8080);

 

  • A trade show magician is without doubt the best way to attract crowds to you stand or booth at a tradeshow event. A trade show magician will provide a human touch, that all important first point of co

 相关资料
  • Magician 是一个基于Netty开发的小型 HTTP服务包,可以非常方便的启动一个http服务,同时也支持WebSocket,注解式Handler配置 运行环境 JDK8+ 文档 https://magician-io.com 示例 导入依赖 <dependency> <groupId>com.github.yuyenews</groupId> <artifactId>Magic

  • Magician-JDBC 是Magician的官方JDBC组件,支持多数据源,无sql单表操作,复杂操作可以写sql,事务管理等 文档 https://magician-io.com 示例 导入依赖 <dependency> <groupId>com.github.yuyenews</groupId> <artifactId>Magician-JDBC</artifactId>

  • Magician-Containers 是 Magician 的官方组件,一个容器管理模块,可以对项目中的bean进行统一管理,它带来了两个扩展:AOP 和定时任务。 文档 https://magician-io.com 示例 导入依赖 <!-- This is the jar package build by this project --><dependency> <groupId>co

  • Magician-Scanning 是一个用 Java 开发的扫描区块链的工具包,当我们在程序中需要一些功能时,它可以派上用场,比如说。 当一个地址收到ETH时,程序中的一个方法会被自动触发,这个交易会被传入该方法。 当一个合约的某个功能被调用时(比如ERC20转账),它会自动触发程序中的一个方法,并将这个交易传递给这个方法。它甚至可以只在代币被转移到指定地址时被触发。 当程序需要保留一个区块高度

  • Magician-Route 是 Magician 的官方 web 组件,由 Magician-Web 发展而来的新项目,主要是去掉了里面的反射,牺牲了一点易用性,将侧重点放在了性能上,两者的区别主要在于路由和拦截器的创建方式上。 引入依赖 在Magician项目的基础上 添加这个依赖 <dependency> <groupId>com.github.yuyenews</groupId>

  •  Magician-ContractsTools 是一个用于调用智能合约的工具包,你可以非常容易地在Java程序中调用智能合约进行查询和写入操作。 有三个内置的标准合约模板,分别是ERC20、ERC721和ERC1155,如果你需要调用这三个合约中的标准函数,可以帮助你非常快速地完成工作。除了内置的合同模板外,如果你需要调用自定义的合同函数也是很容易的,以后我们还会继续增加标准模板。 此外,还有I