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

路由错误 #16

Open
ha666 opened this issue Aug 19, 2019 · 0 comments
Open

路由错误 #16

ha666 opened this issue Aug 19, 2019 · 0 comments

Comments

@ha666
Copy link

ha666 commented Aug 19, 2019

{
  "listen": ":8080",
  "httpVersion": 1,
  "rwTimeout": 5000,
  "keepaliveTimeout": 15000,
  "rewriteTimeout": 10000,
  "noLogGets": false,
  "noLogHeaders": "Accept,Accept-Encoding,Cache-Control,Pragma,Connection",
  "noLogInputFields": false,
  "logInputArrayNum": 0,
  "logOutputFields": "code,message",
  "logOutputArrayNum": 2,
  "logWebsocketAction": false,
  "compress": true,
  "certFile": "",
  "keyFile": ""
}
package main

import (
	"github.com/ssgo/s"
	"net/http"
)

func main() {
	s.Restful(0, http.MethodGet, "/hello/{id}/uploadlog", func() string {
		return "Hello upload\n"
	})
	s.Restful(0, http.MethodGet, "/hello/{id}", func() string {
		return "Hello id\n"
	})
	s.Start()
}

以上是源码,在本地请求的时候:

http://192.168.50.50:8080/hello/1/uploadlog

结果:

Hello id

日志:

2019/08/19 22:16:30.793360 {"app":"","info":"starting","logTime":1566224190.7933598,"logType":"server","node":":8080","proto":"http","startTime":1566224190.7933598,"traceId":"CEVk7dIHEfs","weight":100}
2019/08/19 22:16:30.868963 {"app":"","info":"started","logTime":1566224190.8689635,"logType":"server","node":"192.168.50.50:8080","proto":"http","startTime":1566224190.7933598,"traceId":"CEVk7dIHEfs","weight":100}
2019/08/19 22:16:57.273251 {"app":"","authLevel":0,"clientId":"","clientIp":"192.168.50.50","fromApp":"","fromNode":"","host":"192.168.50.50:8080","logTime":1566224217.2732513,"logType":"request","method":"GET","node":"192.168.50.50:8080","path":"/hello/1/uploadlog","priority":0,"proto":"1.1","requestData":{"id":"1/uploadlog"},"requestHeaders":{"Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36","X-Host":"192.168.50.50:8080","X-Real-Ip":"192.168.50.50","X-Request-Id":"PMTaIkuC4Zuk5BcAo8BodX","X-Scheme":"http"},"requestId":"PMTaIkuC4Zuk5BcAo8BodX","responseCode":200,"responseData":"Hello id\n","responseDataLength":9,"responseHeaders":{},"scheme":"http","serverId":"CEVk7dIHEfs","sessionId":"","traceId":"PMTaIkuC4Zuk5BcAo8BodX","usedTime":0,"type":"ACCESS"}
2019/08/19 22:17:09.333941 {"app":"","info":"stopping router","logTime":1566224229.333941,"logType":"server","node":"192.168.50.50:8080","proto":"http","startTime":1566224190.7933598,"traceId":"CEVk7dIHEfs","weight":100}
2019/08/19 22:17:09.333941 {"app":"","info":"waiting router","logTime":1566224229.333941,"logType":"server","node":"192.168.50.50:8080","proto":"http","startTime":1566224190.7933598,"traceId":"CEVk7dIHEfs","weight":100}
2019/08/19 22:17:09.333941 {"app":"","info":"waiting discover","logTime":1566224229.333941,"logType":"server","node":"192.168.50.50:8080","proto":"http","startTime":1566224190.7933598,"traceId":"CEVk7dIHEfs","weight":100}
2019/08/19 22:17:09.333941 {"app":"","info":"stopped","logTime":1566224229.333941,"logType":"server","node":"192.168.50.50:8080","proto":"http","startTime":1566224190.7933598,"traceId":"CEVk7dIHEfs","weight":100}
```json

我的本意是需要请求:/hello/{id}/uploadlog 这个路由,可是路由错了
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

1 participant