router

Generic generator for http router bases on a route file similar to rails. The generated classes are framework agnostic, whereas several adapters are already provided.

Лицензия

Лицензия

MIT
Группа

Группа

de.leanovate.router
Идентификатор

Идентификатор

parent
Последняя версия

Последняя версия

0.10
Дата

Дата

Тип

Тип

pom
Описание

Описание

router
Generic generator for http router bases on a route file similar to rails. The generated classes are framework agnostic, whereas several adapters are already provided.
Ссылка на сайт

Ссылка на сайт

https://github.com/leanovate/route-generator
Система контроля версий

Система контроля версий

https://github.com/leanovate/route-generator

Скачать parent

Имя Файла Размер
parent-0.10.pom 7 KB
Обзор

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/de.leanovate.router/parent/ -->
<dependency>
    <groupId>de.leanovate.router</groupId>
    <artifactId>parent</artifactId>
    <version>0.10</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/de.leanovate.router/parent/
implementation 'de.leanovate.router:parent:0.10'
// https://jarcasting.com/artifacts/de.leanovate.router/parent/
implementation ("de.leanovate.router:parent:0.10")
'de.leanovate.router:parent:pom:0.10'
<dependency org="de.leanovate.router" name="parent" rev="0.10">
  <artifact name="parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='de.leanovate.router', module='parent', version='0.10')
)
libraryDependencies += "de.leanovate.router" % "parent" % "0.10"
[de.leanovate.router/parent "0.10"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

  • base
  • generator
  • gradle-plugin
  • maven-plugin
  • example

route-generator

Introduction

This is a very generic framework to use Rails-like (or Play framework like) http route files in any java-based web-framework of your choice, including (but not restricted to) plain old java servlets.

Please note: This is a Java 8 project and will not work on Java 7 or lower.

How it works

Consider you have a class SomethingController like this:

pacakge com.myself.project

public class SomethingController {
  public static void index(Response response) {
    ... do something ...
  }

  public static void create(Request request, Response response) {
    ... do something ...
  }
  
  public static void get(String id, Response response) {
    ... do something ...
  }
}

Wheras Request and Response are the request and response classes of your web-framework (line HttpServletRequest and HttpServletResponse in case of servlets).

Now you can define somewhere inside your project (default: src/main/routes) one or more .routes files like this:

something.routes

package com.myself.project

GET  /something      SomethingController.index(response)
POST /something      SomethingController.create(request, response)
GET  /something/:id  SomethingController.get(id, response)

which will be converted to a java class

pacakge com.myself.project

import de.leanovate.router.RouteMatchingContext;
import static de.leanovate.router.CommonRouteRules.*;

public class SomethingRoutes {
  public boolean route(final RouteMatchingContext<Request, Response> ctx0) {
    ... if request matches the rules: calles the methods of SomethingController and returns true
    ... otherwise returns false
  }
}

Its now up to you to integrate this class into your web-framework, by using the approriate adapters or implement them yourself, which should be fairly straight foreward in both cases.

At the moment the following adapters are provided out of the box:

  • Servlet-API 3.1
  • Vert.x

Licence

MIT Licence

de.leanovate.router

Версии библиотеки

Версия
0.10
0.9
0.7
0.6
0.5
0.4