Skip to content

Commit

Permalink
doc: improve README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
vm-001 committed Dec 25, 2023
1 parent 0dfbb1b commit 0800b65
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI pipeline
name: test

on:
pull_request: {}
Expand Down
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
# Lua-radix-router
# Lua-radix-router [![Build Status](https://github.com/vm-001/lua-radix-router/actions/workflows/test.yml/badge.svg)](https://github.com/vm-001/lua-radix-router/actions/workflows/test.yml)

Lua-radix-router is a lightweight high performance router for Lua/LuaJIT.
Lua-radix-router is a lightweight high-performance router written in Lua.

It supports OpenAPI style variables path and prefix matching by using the ` { }` symbol.

## Installation
- `/users/{id}/profile-{year}.{format}`
- `/api/authn/{*path}`

Parameter binding is also supported.

The router is designed for high performance. A compressing dynamic trie (radix tree) is used for efficient matching. Even with millions of routes and complex paths, matching can still be done in 1 nanosecond.

## 🔨 Installation

Install via LuaRocks:

```
luarocks install radix-router
```

## Usage
## 📖 Usage

```lua
local Router = require "radix-router"
Expand Down Expand Up @@ -53,7 +61,7 @@ assert(params.year == "2023")
assert(params.format == "pdf")
```

## Methods
## 📄 Methods

### new
Creates a radix router instance.
Expand All @@ -64,7 +72,7 @@ local router, err = Router.new(routes)

**Parameters**

- **routes **(`table|nil`): the array-like Route table.
- **routes**(`table|nil`): the array-like Route table.



Expand All @@ -74,7 +82,8 @@ Route defines the matching conditions for its handler.
| ----------------------------- | ------------------------------------------------------------ |
| `paths` *required\** | The path list of matching condition. |
| `methods` *optional* | The method list of matching condition. |
| `handler` *required\** | The `handler` will be returned by `router:match()` when the route is matched. |
| `handler` *required\** | The value of handler will be returned by `router:match()` when the route is matched. |
| `priority` *optional* | The priority of the route in case of radix tree node conflict. |
| `expression` *optional* (TDB) | The `expression` defines a customized matching condition by using expression language. |


Expand All @@ -93,4 +102,7 @@ local handler = router:match(path, ctx, params)
- **ctx**(`table|nil`): the optional condition ctx to use for matching.
- **params**(`table|nil`): the optional table to use for storing the parameters binding result.

# Benchmarks
## 🚀 Benchmarks


## License

0 comments on commit 0800b65

Please sign in to comment.