twiglab / twig Goto Github PK
View Code? Open in Web Editor NEWTwig - less is more's web server for golang
Home Page: https://twig.twiglab.dev/doc/
License: MIT License
Twig - less is more's web server for golang
Home Page: https://twig.twiglab.dev/doc/
License: MIT License
我是群里凡人,如题,在行mapScan到map时,可否支持把列名用自定义函数转换,我现在需要的就是把列名转到小写的,谢谢wangsir
ctx.go 的Ctx接口,和mux_radix_ctx.go里面radixTreeCtx的方法的顺序如果一致,更棒
// findChild 从子节点中查找符合一起的接单
希望实现类似于 Flask 的 Blueprint 和 url_for 特性,可以考虑使用 NamedRoute 实现出来,可以选择给路由添加名称,使用 url_for 这样的功能可以直接返回对应的路由 URL 或者 handler
v0.8.9的示例用不了
web := twig.TODO()
web.Config()返回的是Assembler类型,是需要在外面加twig.Config转成*Conf类型吗
ide有使用golint时有76个警告,主页是这些警告:
1)可导出函数没注释;
2)注释不规范;
3)英文缩写没使用全大写;
1,重新实现Ctx
2,重新实现middleware
3,更好的和应用程序集成
根据 go test -bench=.
测试出的结果,注释四行将多157 allocs/op的内存分配,优化成两行独立的Merge。
// ServeHTTP 实现`http.Handler`接口
func (t *Twig) ServeHTTP(w http.ResponseWriter, r *http.Request) {
method, path := r.Method, GetReqPath(r)
c := t.muxes.Lookup(method, path, r)
mc := c.(muxerCtx)
mc.reset(w, r, t)
// h := Merge(func(ctx Ctx) error { //闭包,处理Twig级中间件,结束后处理Pre中间件
// handler := Merge(mc.Handler(), t.mid) // 处理Twig级中间件
// return handler(ctx)
// }, t.pre) // 处理Pre中间件
h := Merge(mc.Handler(), t.mid)
h = Merge(h, t.pre)
if err := h(c); err != nil { // 链式调用,如果出错,交给Twig的HttpErrorHandler处理
t.HttpErrorHandler(err, c)
}
mc.Release()
}
调整名称, 创建方式
提供完整的多路由解决方案和实现,修正之前的路由设计,补充注释
例如函数注释:
// Test this is test function
func Test () {
}
我想用下面的代码加载assets目录下的资源
web := twig.TODO()
web.AddServer(twig.NewServer(":4321"))
web.Config().
Static("/static/*", "/Users/xxx/go/src/xxx/assets/*").
结果报错:
Refused to apply style from 'http://localhost:4321/static/docute.css' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
GET http://localhost:4321/static/docute.js net::ERR_ABORTED 404 (Not Found)
Line 36 in e6440c6
Mr. Wang, why are you so NB?
1, server.go第22行:
func DefaultServnat() *Servant {
函数名是不是应该叫DefaultServant?
2, const.go第134行注释:
defaultHeaderBytes = 1 << 20 // 512k
1 << 20 是1M
模块mount到twig 支持获取twig plugin
bind.go第61行和第71行代码都在else后面,不会走到那里,需要优化
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.