1. 属性
  2. lor:
  3. version
  4. router
  5. route
  6. request
  7. response
  8. fn
  9. app
  10. create_app
  11. Router
  12. Route
  13. Request
  14. Response
  15.  
  16. 属性
  17. lor() 或者 App:
  18. cache
  19. settings --conf函数操作此table设置key --value
  20. router
  21. run(final_handler) /---步骤一---/
  22. init(options)
  23. default_configuration(options)
  24. handle(req, res, callback) /---步骤二 ---*/
  25. use(path, fn) --跳转执行 inner_use(, path, fn) --> (Router:new({})):use('/', fn, ) /**步骤一 **/
  26. erroruse(path, fn)
  27. inner_use(fn_args_length, path, fn)
  28. init_method()--初始化 给自身新增更多的方法
  29. get = true, -- work well
  30. post = true, -- work well
  31. head = true, -- no test
  32. options = true, -- no test
  33. put = true, -- work well
  34. patch = true, -- no test
  35. delete = true, -- work well
  36. trace = true, -- no test
  37. all = true -- todo:
  38. all(path, fn)
  39. conf(setting, val) --设置配置
  40. getconf(setting) --获取配置
  41. enable(setting)--将某项配置开启
  42. disable(setting)--将某项配置关闭
  43.  
  44. 属性
  45. Router:
  46. new(options) /**步骤二 **/
  47. name => 值为 "origin-router-" .. random()
  48. group_router
  49. stack -- 将把实例化后的Layer对象插入到此table /**步骤五 **/
  50. _call()
  51. call()
  52. handle(req, res, out) /---步骤三 ---*/
  53. use(path, fn, fn_args_length) -- 新增路由 /**步骤三 **/
  54. app_route(path) -- 新增路由
  55. route(path) -- 新增路由
  56. init() --初始化 给自身新增更多的方法
  57. get = true, -- work well
  58. post = true, -- work well
  59. head = true, -- no test
  60. options = true, -- no test
  61. put = true, -- work well
  62. patch = true, -- no test
  63. delete = true, -- work well
  64. trace = true, -- no test
  65. all = true -- todo:
  66.  
  67. 属性
  68. Layer:
  69. new(path, options, fn, fn_args_length) /**步骤四 **/
  70. handle => 值为 fn
  71. name => 值为 "layer-" .. random()
  72. params
  73. path => 值为 path
  74. keys
  75. length => 值为 fn_args_length
  76. is_end => 值为 false
  77. is_start => 值为 true
  78. pattern => 值为 "/"
  79. handle_error(err, req, res, next)
  80. handle_request(req, res, next)
  81. match(path) --对每一个路由规则 进行匹配
  82.  
  83. 属性
  84. Request
  85. next
  86. new()
  87. path = ngx.var.uri, -- uri
  88. method = ngx.req.get_method(),
  89. query = ngx.req.get_uri_args(),
  90. params = {},
  91. body = body,
  92. body_raw = ngx.req.get_body_data(),
  93. url = ngx.var.request_uri,
  94. origin_uri = ngx.var.request_uri,
  95. uri = ngx.var.request_uri,
  96. headers = headers, -- request headers
  97. req_args = ngx.var.args,
  98. found = false -- or not
  99. is_found()
  100. set_found(found)
  101.  
  102. 属性
  103. Response
  104. http_status = nil,
  105. headers = {},
  106. locals = {},
  107. body = '--default body. you should not see this by default--',
  108. view = nil
  109. render(view_file, data)
  110. html(data)
  111. redirect(url, code, query)
  112. location(url, data)
  113. send(text)
  114.  
  115. main.lua
  116. 路线一:
  117. app --> lor() --执行那个 “函数A --> Application.lua文件的返回 返回新table 并将Application类设为新table的元方法
  118. 注意:Application 下有如下方法
  119. get = true, -- work well
  120. post = true, -- work well
  121. head = true, -- no test
  122. options = true, -- no test
  123. put = true, -- work well
  124. patch = true, -- no test
  125. delete = true, -- work well
  126. trace = true, -- no test
  127. all = true -- todo:
  128. 值等于同一个函数 function(path, fn)
  129. local route = router:app_route(path)
  130. route[http_method](route, fn) -- like route:get(fn)
  131. return self
  132. end
  133.  
  134. --> lor.lua文件的返回 传入 一个“函数A“进去
  135. --> wrap.lua文件的返回 返回新table 并将wrap类设为新table的元方法
  136.  
  137. 路线二:
  138. app:use(函数)--> App:use() 没有返回值 --> App:inner_use() 返回self
  139. --> Router:use() 返回self 并设置了 table.insert(self.stack, layer:new())
  140. --> Layer:new() 返回新table 并将 Layer类设为新table的元方法
  141.  
  142. 路线三:
  143. app:run() --> App:run() --> App:handle()-->router:handle //作者在此函数下了不少功夫.,.....

lor框架代码分析的更多相关文章

  1. 一个简单的"RPC框架"代码分析

    0,服务接口定义---Echo.java /* * 定义了服务器提供的服务类型 */ public interface Echo { public String echo(String string) ...

  2. PHPCMS V9 框架代码分析(入口程序)

    PHPCMS是采用MVC设计模式开发,基于模块和操作的方式进行访问,采用单一入口模式进行项目部署和访问,无论访问任何一个模块或者功能,只有一个统一的入口. 入口程序是在前期处理用户请求的引导程序.它是 ...

  3. Linux摄像头驱动学习之:(六)UVC-基本框架代码分析

    仿照内核的自带UVC(usb video class)驱动程序写的一版简化驱动,仅供学习,实际项目开发中应该尽量使用内核自带的驱动,除非内核自带的驱动不支持此款硬件才需要自己写驱动. 下面就直接上代码 ...

  4. 开源代码分析之Android/iOS Hybrid JSBridge框架

    Hybrid开发是现在的主流形式,对于业务快速迭代的公司尤其重要.曾将在鞋厂接触了很多关于Hybrid的理念,在这里分享一些Hybrid框架思想. Hybrid框架包括Native与H5的通信,Web ...

  5. 11.5 Android显示系统框架_Vsync机制_代码分析

    5.5 surfaceflinger对vsync的处理buffer状态图画得不错:http://ju.outofmemory.cn/entry/146313 android设备可能连有多个显示器,AP ...

  6. 完整全面的Java资源库(包括构建、操作、代码分析、编译器、数据库、社区等等)

    构建 这里搜集了用来构建应用程序的工具. Apache Maven:Maven使用声明进行构建并进行依赖管理,偏向于使用约定而不是配置进行构建.Maven优于Apache Ant.后者采用了一种过程化 ...

  7. 动态加载框架DL分析

    动态加载框架DL分析 插件化开发,主要解决三个问题1.动态加载未安装的apk,dex,jar等文件2.activity生命周期的问题,还有service3.Android的资源调用的问题 简单说一下怎 ...

  8. angular代码分析之异常日志设计

    angular代码分析之异常日志设计 错误异常是面向对象开发中的记录提示程序执行问题的一种重要机制,在程序执行发生问题的条件下,异常会在中断程序执行,同时会沿着代码的执行路径一步一步的向上抛出异常,最 ...

  9. Linux内核中的GPIO系统之(3):pin controller driver代码分析

    一.前言 对于一个嵌入式软件工程师,我们的软件模块经常和硬件打交道,pin control subsystem也不例外,被它驱动的硬件叫做pin controller(一般ARM soc的datash ...

随机推荐

  1. sql 内联,左联,右联,全联

    联合查询效率较高,以下例子来说明联合查询(内联.左联.右联.全联)的好处: T1表结构(用户名,密码) userid (int) username varchar(20) password  varc ...

  2. jenkins 入门教程(上)【转】

    转自:https://www.cnblogs.com/yjmyzz/p/jenkins-tutorial-part-1.html jenkins是一个广泛用于持续构建的可视化web工具,持续构建说得更 ...

  3. Django Xadmin - 重构django admin

    一.Django admin的执行流程 https://www.cnblogs.com/weihengblog/p/9122509.html 我的博客,介绍了django admin执行流程 二.Xa ...

  4. vue实现结算淘宝购物车效果

    实现单选时的价格,全选时价格 单选效果图 全选效果图 html <template> <!-- 淘宝结算购物车 --> <div class="settleme ...

  5. dedecms调用文章列表第一篇和下面几篇不同的方法

    {dede:arclist row=1 orderby=pubdate infolen=60 limit=0,1} <li class="dot1"><img s ...

  6. mysqlsla 安装

    tar -zxvf mysqlsla-2.03.tar.gz cd mysqlsla-2.03 perl Makefile.PLmake && make install BEGIN f ...

  7. MFC+WinPcap编写一个嗅探器之四(获取模块)

    这一节主要介绍如何获取设备列表,比较简单 获取设备列表主要是在CAdpDlg中完成,也就是对应之前创建的选择适配器模块,如图: 当打开选择适配器对话框后,在列表视图控件中显示当前主机所有适配器及适配器 ...

  8. [水煮 ASP.NET Web API2 方法论](1-4)从 MVC Controller 链接到 API Controller 以及反向链接

    问题 想创建一个从 ASP.NET MVC controller 到 ASP.NET Web API controller 的直接链接,或者反向链接. 解决方案 可以使用 System.Web.Htt ...

  9. BZOJ 1861: [Zjoi2006]Book 书架 (splay)

    1861: [Zjoi2006]Book 书架 Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 1453  Solved: 822[Submit][Stat ...

  10. hdu 5936 2016ccpc 杭州 - D

    数学题好难啊!!!! 最长长度不超过十位, 折半枚举... 题解 #include<bits/stdc++.h> #define LL long long #define fi first ...