Kanary: Kotlin-based Extensible RESTful API Web Framework

License:Apache 2.0 Download:0.9.0Code Climate:1 issues

Kanary is a KotlinWeb framework for building scalable and expressive RESTful APIs based on Apache 2.0 and hosted on Github. Kanary was founded by Iyanu Adelekan, who is currently the project leader.

installation

The installation resources are contained in the com.iyanuadelekan.kanary package. You can import this package through Maven, Gradle, and Ivy in your application. Introduce the following code in your application:

Maven

Include Jcenter as a plug-in library

Add Kanary as a project dependency

Gradle

Ivy

other

For other use cases, you can download the jar from bintray

feature

Performance routing

Focus on code clarity

Support controller

Include HTTP helper

Full support for asynchronous middleware

Concise English, such as "first line"

Available action lifecycle callback methods

Quick start

This is a detailed [Packages]: https://github.com/SeunAdelekan/Kanary#packages

Create a Kanary application and start the server

By initializing KanaryApp, create a Server object, an AppHandler instance, set the instance as the server's handler and start the server listening on the specified port, creating a simple Kanary application.

Create controller

The controller is an instance of the extended KanaryController class. The following class is a simple controller class that does nothing.

Create an action controller

Although the above controller class is correct, usually you need to specify actions in the controller to route the request.

An action is a controller function that takes three arguments as arguments:

An instance of the request (a mutable request object)

An instance of HttpServletRequest (an immutable request object)

An instance of HttpServletResponse (response object)

Display a valid action in the following controller:

Action controller life cycle callback

Two different action lifecycle callbacks can be declared in KanaryController. they are, respectively:

beforeAction, if declared, executes immediately before the action is performed

afterAction if declared, executes immediately after the action is performed

Declaring these two callbacks is as simple as declaring a function in the controller:

routing

All routes are completed by one or more designated routers. The route is an instance of KanaryRouter:

Declaring the routing path

The above can also be used:

Install Router to Application

A single route can be mounted to an instance of KanaryApp as follows:

Numerous routes can be installed at any time:

Middleware

All middleware is in the form of a lambda. A single, nullable instance of HttpServletRequest is passed to each middleware added to the application.

You can add multiple middleware at any time:

It is important to note that all middleware executes in a non-blocking manner parallel to the main application thread.

Bundled middleware

The only middleware bundled with Kanary is "simpleConsoleRequestLogger". It prints concise information about each request received to the console.

Handling requests and responses

Processing request

In most cases, request processing completes an action response by creating an HttpServletRequest. This HttpServletRequest is an object of Java and it is a Kanary-specific helper function. The additional features provided include:

A mutable request object is displayed as a request instance. The HttpServletRequest request is implemented so it has similar behavior and features as the HttpServletRequest instance passed to it. In addition to the features shown in the table above, the passed request instances are:

Response request

Use HttpServletResponse to send an action response to the client. In addition to all the features and behavior exposed by this example, the following Kanary-specific helper functions can also be used:

All functions except "sendFile" can be written with infix symbols (the recommended way of writing code in Kanary). This can write clear and expressive code to respond to customers. This will send the client a plain text message:

Packages

Dependencies

Jetty (as an application server engine):

Jackson-databind (for JSON serialization/deserialization):

Philosophy (Principle)

Kanary was created to enable stable and non-verbal RESTful APIs using the Kotlin programming language.

Conventions and Configuration

Kanary aims to help engineers and developers create microservice-based applications in an efficient way. For this method, developers do not enforce the agreement. The method of implementing the application is left to the discretion of the implementer.

Road map (road map)

RAM Memory

Ram Memory,Laptop Ram,Ram Computer,Computer Memory

MICROBITS TECHNOLOGY LIMITED , https://www.hkmicrobits.com