Skip to content
forked from xphh/happor

A netty-spring-based web controller framework.

License

Notifications You must be signed in to change notification settings

weibingo/happor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

happor

A netty-spring-based web controller framework.

I consider that Netty bound with SpringMVC could be a very nice web MVC framework instead of Tomcat + Servlet + SpringMVC.

However, SpringMVC is based on Servlet and, it's hard to dettach Servlet from SpringMVC. In some implements, we may only focus on controller usage, such as RESTful API develop.

Things can be simplification. By using Spring IoC to make a controller framework based on Netty without Servlet, I setup this project.

#A hello-world demo

@Controller(method="GET", uriPattern="^/test/(\\w+)")
public class Test extends HttpNormalHandler {
	
	@UriSection(1)
	private String name;

	@Override
	protected void handle(FullHttpRequest request, FullHttpResponse response) {
		// TODO Auto-generated method stub
		String words = "hello " + name;
		response.content().writeBytes(words.getBytes());
		response.headers().set("Content-Type", "text/plain");
		response.headers().set("Content-Length", response.content().readableBytes());
	}

	@Override
	protected void atlast() {
		// TODO Auto-generated method stub
		
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		HapporAutomaticContext context = new HapporAutomaticContext();
		context.runServer();
	}

}

Run and visit http://localhost/test/someone, the browser will show hello someone.

About

A netty-spring-based web controller framework.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 99.7%
  • Other 0.3%