8000 GitHub - amaziagur/blink-java: Simplified http server, made primarily for using in tests
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

amaziagur/blink-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blink-java

Simplified http server, made primarily for using in tests It also doesn't have any dependencies other than those that come with Oracle's Jdk It's inspired by Spark and Sinatra

Artifactory

This package is available at https://bintray.com/rockem/maven/blink-java

Usage

Hello World

Java

new BlinkServer(1234) {{
	get("/hello", (req, res) -> "Hello World");
}};

Groovy

new BlinkServer(1234) {{
	get("/hello", { req, res -> "Hello World" })
}}

Path parameters

new BlinkServer(1234) {{
	delete("/hello/{id}", (req, res) -> "Delete " + req.pathParam("id"));
}};

Default content type

new BlinkServer(1234) {{
    contentType("application/json")
    get("/hello", (req, res) -> "{\"greeting\": \"Hello World\"}");
}};

Request

req.body()						// request body
req.param("name")				// Query parameter
req.pathParam("name")			// Path parameter
req.uri()						// Request uri
req.header("name")				// header value
req.cookie("name")				// cookie value

Response

res.status(201)					// set retrun status code
res.header("name", "value")		// Set header 
res.type("type")				// Set content type
res.cookie("name", "value")		// Add/Update cookie

About

Simplified http server, made primarily for using in tests

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 98.8%
  • Groovy 1.2%
0