Version: 0.6.1
Small, simple, and lightweight HTTP server and client library with no dependencies.
Using Postman as a client, the HTTP server responds within 2-3ms, which is faster than many popular alternatives.
Other HTTP libraries had the issue of having a large dependency tree and a lot of setup to make even the most basic of endpoints. The Scala ecosystem really needed an easy-to-use and simple library with no fuss, and that's what mouse is!
Our goals:
- Easy to use
- Simple to reason about
- Quick to install
- Great performance
- Works from prototype to production
In your build.sbt:
libraryDependencies ++=Seq(
// ..."io.github.aliics"%%"mouse"%"0.6.1",
// ...
)mouse's layout is very simple, there are only two imports you will need:
importmouse.*// For our Server, Client, etc. importmouse.types.*// For our Request, Response, etc.Setting up a Server is as easy as providing
some Routes and a port! Then calling run or runBlocking.
Server(
routes(
Method.Get/"hello"/"world"-> greetWorld,
// ... More routes
) *
).runBlocking(port =8080)A Client is even easier!
Client("localhost", port =8080)
.getBlocking("hello/alex") // GET Request was made, and we awaited the Response.
.textBlocking() // The body of the response.All HTTP method helper methods have a "blocking" wrapper for convenience. Generally, you'll want to use the async ones
(getBlocking -> get).
Full examples exists in the examples directory.
Get your fork and make a pull request! We'll go from there.