Giter Club home page Giter Club logo

tigo's People

Contributors

blessurb avatar fugui1234 avatar iinjil avatar karldoenitz avatar linzhai avatar ssundabao avatar treenewbeef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tigo's Issues

logger包增加docs

Tigo.logger包需要增加一个doc.go文件,增加一个文档文件,写明logger包的用法。

ReadMe文件中性能对比图连接需要换一下

第82行md标签:

<img src="https://github.com/karldoenitz/Tigo/blob/master/documentation/chart.png" width="100%" height="300px" alt="性能对比"/> 

替换成如下所示:

<img src="https://raw.githubusercontent.com/karldoenitz/Tigo/master/documentation/chart.png" width="100%" height="300px" alt="性能对比"/> 

ResponseAsHtml返回数据乱码

【代码定位】点击此处
【问题描述】使用ResponseAsHtml方法返回数据中包含中文则会乱码
【解决方案】在content-type中应该增加charset,建议将charset设为参数,默认为utf-8

参数校验模块,布尔校验默认不应该为false

  • go version: v 1.10+
  • Tigo version (or commit ref): v 1.6.2
  • operating system:

Description

【问题描述】校验json或者form参数的时候,输入大于0的数字默认为false,必须输入true才认定为true

Operation

【操作步骤】按照api写一个用例即可发现

Analysis(optional)

【问题分析】validate.go/checkBasicField函数

PassJson代码修改

Description

【问题描述】客户端发送http请求,发送json有时候会报错

Operation

【操作步骤】设置Content-Type: application/json; charset=utf-8,发送json,就会报错。

Analysis(optional)

【问题分析】PassJson函数的56行要改成判断Content-Type是否包含application/json

ResponseAsJson特殊字符乱码

【代码定位】点击此处
【关联问题】点击此处
【问题描述】使用ResponseAsJson方法返回数据中包含特殊字符则会乱码
【解决方案】在content-type中应该增加charset,建议将charset设为参数,默认为utf-8

CheckFormBinding错误

  • go version: all
  • Tigo version (or commit ref): all
  • operating system: all

Description

【问题描述】使用CheckFormBinding和CheckParamBinding都不能检验form的合法性

Operation

【操作步骤】直接post请求,就会复现

Analysis(optional)

【问题分析】binding.UnmarshalForm有bug,测试用例没有覆盖这个函数,修复这个函数即可。

logger模块初始化失败问题兼容

Description

【问题描述】
logger模块初始化失败后直接抛出panic

Analysis(optional)

【问题分析】
logger模块init方法中如果获取当前绝对路径失败,会抛出异常,改成异常打印。

binding包增加docs

Tigo.binding包需要增加一个doc.go文件,增加一个文档文件,写明binding包的用法。

tiger工具不能更新项目

  • With issues:

    • Use the search tool before opening a new issue.
    • Please provide source code and commit sha if you found a bug.
    • Review existing issues and provide feedback or react to them.
  • go version: 1.9

  • Tigo version (or commit ref):1.0.7

  • operating system:Windows8

Description

[description]
【问题描述】tiger update更新框架不成功

Operation

[operation]
【操作步骤】直接直行update命令

request包增加docs

Tigo.request包需要增加一个doc.go文件,增加一个文档文件,写明request包的用法。

删除Travis-CI的配置,迁移到github action

Travis-CI开始收费了,之前配置的CI已经不能用了,需要迁移到github自己免费的CI上使用。
示例如下:

![action图标](https://github.com/dotnet-campus/dotnetcampus.DotNETBuildSDK/workflows/.NET%20Core/badge.svg)

`tiger`命令生成cookie对应的secret key

  • go version: 1.12+
  • Tigo version (or commit ref): 1.6+
  • operating system: Mac OSX, Windows, Linux

Description

【问题描述】tiger命令生成的secret key太简单了,容易被猜到。

getHttpRequestMsg报错

Description

【问题描述】客户端发送http请求,发送json有时候会报错

Operation

【操作步骤】设置Content-Type: application/x-www-form-urlencoded; charset=utf-8,发送json,就会报错。

Analysis(optional)

【问题分析】getHttpRequestMsg函数的56行要改成判断Content-Type是否包含application/x-www-form-urlencoded

redirctpermanetly无法重定向

  • go version: all
  • Tigo version (or commit ref): all
  • operating system: all

Description

【问题描述】永久重定向无效

Operation

【操作步骤】
执行如下代码:

package main

import "github.com/karldoenitz/Tigo/TigoWeb"

type HelloWorldHandler struct {
	TigoWeb.BaseHandler
}

func (h *HelloWorldHandler) Get() {
	h.RedirectPermanently("https://www.github.com")
}

var urls = []TigoWeb.Router{
	{"/hello-world", &HelloWorldHandler{}, nil},
}

func main() {
	application := TigoWeb.Application{IPAddress: "0.0.0.0", Port: 8888, UrlRouters: urls}
	application.Run()
}

Analysis(optional)

【问题分析】

  • 先ResponseWriter.WriteHeader,再调用SetHeader,不会生效
  • 需要先进行SetHeader
    将代码改为如下即可
// RedirectPermanently 向客户端永久重定向一个地址
func (baseHandler *BaseHandler) RedirectPermanently(url string) {
	baseHandler.SetHeader("Location", url)
	baseHandler.ResponseWriter.WriteHeader(http.StatusMovedPermanently)
	baseHandler.ResponseWriter.Write(nil)
}

Tigo version number incorrect

Description

[description] Tigo version number is incorrect

Operation

[operation] run the command tiger version

Analysis(optional)

[analysis] the version number in enums is wrong

静态文件服务没有挂载中间件

  • go version: v1.10+
  • Tigo version (or commit ref): v1.6.2
  • operating system: MacOS Windows Linux

Description

【问题描述】静态文件服务没有挂载中间件

Operation

【操作步骤】写一个中间件即可复现

Analysis(optional)

【问题分析】handler和fileserver分开挂载了

DumpHttpRequestMsg功能异常

如果request请求的Content-Type是application/x-www-urlencoded-form的时候,这个函数没有打印报文体。

关于 Response 接口?

RT, 小白有个疑问,为什么 Response 类型不直接定义一个空接口,感觉现在这种写起来有点拖沓。还是我写法有问题?

helloHandler.ResponseAsJson(struct {
	TigoWeb.Response
	Status string `json:"status"`
}{Status: "ok"})

另外 还有两点建议:

  • 例子中可以添加 ResponseAsJson 的实列吗?
  • 示例中的 IP 建议还是设置为 127.0.0.1 吧,设置 0.0.0.0 有点坑0.0

出现500错误时连接中断,并没有响应客户端

  • go version: 1.x
  • Tigo version (or commit ref): 1.0.3
  • operating system: Windows Linux Mac都有这个问题

Description

【问题描述】服务运行时出现错误,无论什么错误,直接服务就中断了,没有给客户端任何响应。

Operation

【操作步骤】在Handler中panic一下就可以复现。

Analysis(optional)

【问题分析】框架的中间层代码并没有对错误异常进行recover处理。

建议增加ErrorResponse函数

【问题描述】
建议增加Error函数,在框架自带的几个response函数中,只有成功的,如果有Error的情况需要我们自己设置http的status。

API优化建议

  • 建议增加两个重定向的API,分别对应http状态码307308;
    【问题描述】
  • 目前的BaseHandler.RedirectBaseHandler.RedirectPermanently都会使浏览器默认采用Get请求方式,但根据RFC7231的标准,当使用307308两种状态码时,不允许重定向时发生请求方式变化。

多线程输出异常

  • go version: all
  • Tigo version (or commit ref): all
  • operating system: all

Description

[description]
【问题描述】客户端开多进程或多线程,请求服务端,返回数据紊乱

Operation

[operation]
【操作步骤】随便找一种编程语言,多线程3000个请求

Analysis(optional)

[analysis]
【问题分析】连接公用一个对象,没有重新实例化responsewriter造成的

上下文设置bug

Description

【问题描述】SetCtxVal和GetCtxVal有bug,并不是整的将值写入上下文

file server挂载失败

  • go version: 1.12
  • Tigo version (or commit ref): bfe6a12
  • operating system: MacOS / Linux / Win

Description

【问题描述】调用MountFileServer函数挂载file server失败

Operation

【操作步骤】写个demo测试即可发现

Analysis(optional)

【问题分析】换了路由插件造成的

request模块的测试用例有抛出nil的可能

Description

【问题描述】在测试用例中没有对返回值是否是nil进行判断,可能会导致抛出异常。

Analysis(optional)

【问题分析】对可能出现nil的地方没有进行nil捕获判断。

不能安装

go get github.com/karldoenitz/Tigo/...
go: warning: "github.com/karldoenitz/Tigo/..." matched no packages

中间件重构bug

  • go version: 1.9+
  • Tigo version (or commit ref): 8147452
  • operating system: MacOS, Linux, Windows

Description

【问题描述】按照新的api,编写多个中间件,只有一个生效

Operation

【操作步骤】按照demo写一个就可以发现。

Analysis(optional)

【问题分析】问题出现在TigoWeb.urlpattern.go的第60行,函数代码如下:

// AppendRouterPattern 向http服务挂载单个Router,Router中配置有url对应的handler以及对应的中间件
func (urlPattern *UrlPattern) AppendRouterPattern(pattern Pattern, v interface {
	Handle(http.ResponseWriter, *http.Request)
}) {
	// 判断是否是文件服务器
	if filePath, isFileServer := pattern.Handler.(string); isFileServer {
		fileRouter := urlPattern.router.PathPrefix(pattern.Url).Subrouter()
		var fileServerMiddleWares []mux.MiddlewareFunc
		for _, v := range pattern.Middleware {
			fileServerMiddleWares = append(fileServerMiddleWares, func(next http.Handler) http.Handler {
				return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
					// 此处需要判断请求是否继续交给下一个中间件处理
					if isGoOn := v(&w, r); isGoOn {
						next.ServeHTTP(w, r)
					}
				})
			})
		}
		fileRouter.Use(fileServerMiddleWares...)
		fileRouter.PathPrefix("/").Handler(http.StripPrefix(pattern.Url, http.FileServer(http.Dir(filePath))))
		return
	}
	// 判断是否是handler
	baseMiddleware := []middleware{HttpContextLogMiddleware, InternalServerErrorMiddleware}
	for _, v := range pattern.Middleware {
		baseMiddleware = append(baseMiddleware, func(next http.HandlerFunc) http.HandlerFunc {
			return func(w http.ResponseWriter, r *http.Request) {
				// 此处需要判断请求是否继续交给下一个中间件处理
				if isGoOn := v(&w, r); isGoOn {
					next.ServeHTTP(w, r)
				}
			}
		})
	}
	middlewares := chainMiddleware(baseMiddleware...)
	urlPattern.router.HandleFunc(pattern.Url, middlewares(v.Handle))
}

函数不能采用内置代码片段的方式来实现,这样在golang内用的都是同一块内存,多少个函数都是只生效最后一个。应该用一个转换函数,入参是Tigo的中间件,出参是标准中间件,这样开辟了新的内存,就可以解决这个问题。

DumpHttpRequestMsg不能工作

func (baseHandler *BaseHandler) DumpHttpRequestMsg(logLevel int)

当content-type是application/json的时候接口报错;
而且当content-type是application/x-www-form-urlencoded的时候,打印的报文没有报文体。

接口访问时log级别问题

Info

  • go version: all
  • Tigo version (or commit ref): all
  • operating system: all

Description

【问题描述】
访问接口时打印的log,级别都是trace级别,不严谨,trace一般是跟进问题时使用此级别。

Operation

【操作步骤】
随机访问一个接口查看log即可。

Analysis(optional)

【问题分析】
Trace级别是跟进排查,普通的log打印使用info就可以。

基于gorilla的文件服务系统bug

  • go version: v1.10+
  • Tigo version (or commit ref): v1.6.2
  • operating system: MacOS Windows Linux

Description

【问题描述】
文件服务系统和url映射互相冲突

Operation

【操作步骤】
设置url则文件挂载无效,反之则url无效

Analysis(optional)

【问题分析】
文件挂载使用的前缀匹配"/"会使后续挂载的url无效。代码Application.go/MountFileServer

文档跳转错误

【问题描述】
文档跳转错误,不能跳转到指定位置。
【操作步骤】
例如:
image
跳转结果:
image

【问题分析】
锚链接异常,应该使用markdown自支持的结构,不能使用html的锚链接方式。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.