Harry Huang
Harry Huang
首先感谢楼主让我也注意到了这个问题. 除了楼主的做法, 我觉得也可以参考代码作者调用其他Logger方法的位置, 将 `(*Logger).WithCaller()` 放到 `(*Logger).Infof()` 等函数中, 不过需要在所有输出函数上都加上, 没有楼主简洁, 但效果是一样的. ```go func (l *Logger) Infof(ctx context.Context,format string, v ...interface{}) { l.WithContext(ctx).WithTrace().WithCaller(2).Output(LevelInfo, fmt.Sprintf(format, v...)) } ```
首先感谢楼主让我也注意到了这个问题, 关于判断前缀匹配, 能否使用如下的代码呢? 我感觉可能会简洁一些. 其中, `req.URL.Path == group.prefix` 对应楼主 `len(req.URL.Path) > len(group.prefix)` 而后者 `strings.HasPrefix(req.URL.Path, group.prefix+"/")` 对应 `request.URL.Path[len(group.prefix)] != '/'` ```go if req.URL.Path == group.prefix || strings.HasPrefix(req.URL.Path, group.prefix+"/") { middlewares =...