lapis 路由
参考如下:
local lapis = require("lapis")
local app = lapis.Application()
app:match("/", function(self) end) // 必须的
app:match("/hello", function(self) end)
app:match("/users/all", function(self) end)
// 包含请求参数的 使用:
app:match("/page/:page", function(self)
print(self.params.page) // 打印输出参数, 比如 /page/dalong 输出 {page:"dalong"}
end)
// 可选路由参数(使用括号)
/projects/:username(/:project)
// * 符号,匹配尽可能多的参数,说白了,就是url 参数中其余的
app:match("/browse/*", function(self)
print(self.params.splat)
end)
app:match("/user/:name/file/*", function(self)
print(self.params.name, self.params.splat)
end)
a. 完全匹配 /hello/world
b. 变量路由 /hello/:variable
c. 统配路由 /hello/*
// 参考如下:
local lapis = require("lapis")
local app = lapis.Application()
app:match("index", "/", function(self)
return self:url_for("user_profile", { name = "leaf" })
end)
app:match("user_profile", "/user/:name", function(self)
return "Hello " .. self.params.name .. ", go home: " .. self:url_for("index")
end)
lapis 路由的更多相关文章
- kong插件官方文档翻译
kong插件官方文档翻译 目录 介绍 文件结构 编写自定义逻辑 存储配置 访问数据存储 自定义实体 缓存自定义实体 扩展Admin API 编写测试 (卸载)安装你的插件 插件开发 - 介绍 什么是插 ...
- lapis 项目添加prometheus 监控集成grafana
操作很简单,主要是进行界面的配置以及prometheus 服务的配置, 可以和https://www.cnblogs.com/rongfengliang/p/10074044.html &&a ...
- lapis http verb 处理
1. 同一个url 包含不同的请求(respond_to 进行解决) // 路由格式 match ,通过respond_to 进行实际的http verb 处理 local lapis = requ ...
- Angular2入门系列教程6-路由(二)-使用多层级路由并在在路由中传递复杂参数
上一篇:Angular2入门系列教程5-路由(一)-使用简单的路由并在在路由中传递参数 之前介绍了简单的路由以及传参,这篇文章我们将要学习复杂一些的路由以及传递其他附加参数.一个好的路由系统可以使我们 ...
- Angular2入门系列教程5-路由(一)-使用简单的路由并在在路由中传递参数
上一篇:Angular2入门系列教程-服务 上一篇文章我们将Angular2的数据服务分离出来,学习了Angular2的依赖注入,这篇文章我们将要学习Angualr2的路由 为了编写样式方便,我们这篇 ...
- nodejs进阶(3)—路由处理
1. url.parse(url)解析 该方法将一个URL字符串转换成对象并返回. url.parse(urlStr, [parseQueryString], [slashesDenoteHost]) ...
- .NetCore MVC中的路由(2)在路由中使用约束
p { margin-bottom: 0.25cm; direction: ltr; color: #000000; line-height: 120%; orphans: 2; widows: 2 ...
- .NetCore MVC中的路由(1)路由配置基础
.NetCore MVC中的路由(1)路由配置基础 0x00 路由在MVC中起到的作用 前段时间一直忙于别的事情,终于搞定了继续学习.NetCore.这次学习的主题是MVC中的路由.路由是所有MVC框 ...
- ASP.NET路由模型解析
大家好,我又来吹牛逼了 ~-_-~ 转载请注明出处:来自吹牛逼之<ASP.NET路由模型解析> 背景:很多人知道Asp.Net中路由怎么用的,却不知道路由模型内部的运行原理,今天我就给大家 ...
随机推荐
- JS触发服务器控件的单击事件
<script src="../Js/jquery-1.4.2.min.js" type="text/javascript"></script ...
- CAJ2PDF
该项目不成熟,很容易遇到转换失败的例子. https://github.com/JeziL/caj2pdf https://github.com/JeziL/caj2pdf/wiki caj2pdf ...
- LeetCode 525. Contiguous Array
525. Contiguous Array Add to List Description Submission Solutions Total Accepted: 2476 Total Submis ...
- [myeclipse]@override报错问题
@Override是JDK5 就已经有了,但有个小小的Bug,就是不支持对接口的实现,认为这不是Override 而JDK6 修正了这个Bug,无论是对父类的方法覆盖还是对接口的实现都可以加上@Ove ...
- 《深入理解mybatis原理3》 Mybatis数据源与连接池
<深入理解mybatis原理> Mybatis数据源与连接池 对于ORM框架而言,数据源的组织是一个非常重要的一部分,这直接影响到框架的性能问题.本文将通过对MyBatis框架的数据源结构 ...
- nyi63——树
#include<bits/stdc++.h> using namespace std; int cnt; struct node { int data; int flag; node * ...
- 纯css做三角形形状
/* create an arrow that points up */ div.arrow-up { width:0px; height:0px; border-left:5px solid tra ...
- guava学习--cache
转载:http://outofmemory.cn/java/guava/cache/how-to-use-guava-cache http://www.cnblogs.com/parryyang/ ...
- L3-010. 是否完全二叉搜索树
L3-010. 是否完全二叉搜索树 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 将一系列给定数字顺序插入一个初始为空的二叉搜 ...
- maven_00_资源帖
一.官方资料 Maven Getting Started Guide 二.精选资料 Maven for building Java applications - Tutorial Maven Tuto ...