

gobox中的http请求处理框架
source link: http://blog.7rule.com/2018/08/24/gobox-http-mvc.html?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

今天来说下使用gobox中的http请求处理框架
http请求处理架构图
重要的对象
System
system用于实现go官方包中的http.Handler接口,它的ServeHTTP方法中实现了请求处理框架。
Router
定义和实现MVC的路由查找过程。
type Router interface { MapRouteItems(cls ...controller.Controller) // 自动将Controller对象中的Action方法映射到路由表 DefineRouteItem(pattern string, cl controller.Controller, actionName string) // 手动添加路由规则,pattern为正则表达式 FindRoute(path string) *Route // 实现路由查找过程 }
SimpleRouter
Router接口的一个实现,自动映射规则为:
- controller名称规则为:
([A-Z][A-Za-z0-9_]*)Controller$
,匹配内容转小写即为controllerName - action名称规则为:
^([A-Z][A-Za-z0-9_]*)Action$
,匹配内容转小写后过滤掉before和after
即为actionName
自动路由查找规则如下:
/controller/action index index
自定义路由查找规则如下:
- 对request_uri做正则匹配
- 如果匹配后存在捕获,则捕获内容会作为action中除context外的参数,依次传入,都是string类型
gracehttp
这是一个支持平滑重启的httpserver
欢迎大家使用,使用中有遇到问题随时反馈,我们会尽快响应,谢谢!
Recommend
-
42
今天来说下gobox中的连接池底层实现pool 为什么需要连接池 我们的系统在访问外部资源(redis、mysql等)时,为了提高性能,通常会用到的一个优化方法就是把已经使用过的tcp连接保存起来,这样当需要再次使用时,就可...
-
39
我们都会有从异步队列中消费的需求,今天来说下gobox中的consumer处理框架 consumer处理架构图 重要的对象 IM...
-
19
HAProxy 研究笔记 -- HTTP请求处理-2-解析 2015-07-29 16:07:00 http://blog.chinaunix.net/uid-10167808-id-3819702.html 本文继续...
-
20
HAProxy 研究笔记 -- HTTP请求处理-1-接收 2015-07-29 16:03:00 http://blog.chinaunix.net/uid-10167808-id-3795082.html 这里...
-
11
官方介绍,Flurl是一个现代的,流利的,支持异步的,可测试的,可移植的,URL增强和Http客户端组件。 Url构建 现在有一个登录的接口,地址如下: https://www.some-api.com/login?name=Lee&pwd=123456 我...
-
11
V2EX › Java Java http 请求中如何处理外部回调? wangsongyan · 7 小时 40 分钟前 · 526...
-
13
Python HTTP 请求时对重定向中的 cookie 的处理 本文来自依云's Blog,转载请注明。 首先说明一下,...
-
4
Go实战 | http请求排队处理的实现 yudotyang · 1天之前 · 363 次点击 ·...
-
9
Axum框架自动处理请求的神奇函数 解道Jdon ...
-
1
thinkphp 框架HTTP请求流程 对于一个HTTP应用来说,从用户发起请求到响应输出结束,大致的标准请求流程如下: 载入Composer的自动加载autoload文件...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK