Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请支持自动响应options请求 #13

Open
wencan opened this issue Dec 13, 2018 · 1 comment
Open

请支持自动响应options请求 #13

wencan opened this issue Dec 13, 2018 · 1 comment

Comments

@wencan
Copy link

wencan commented Dec 13, 2018

主流go语言http路由解析组件默认是这么玩的:
当收到options请求,只要请求路径能匹配到路由表中的任一url模式(不管http方法为何),则返回200,否则返回404

目前ssgo不支持该特性,请支持

@wencan wencan changed the title 请自动响应options请求 请支持自动响应options请求 Dec 13, 2018
@xujintao
Copy link
Contributor

Every net/http based http framework can support options method with any url request.
$GOROOT/src/net/http/server.go, line 2733~line 2742

func (sh serverHandler) ServeHTTP(rw ResponseWriter, req *Request) {
	handler := sh.srv.Handler
	if handler == nil {
		handler = DefaultServeMux
	}
	if req.RequestURI == "*" && req.Method == "OPTIONS" {
		handler = globalOptionsHandler{}
	}
	handler.ServeHTTP(rw, req)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants