Skip to content
This repository has been archived by the owner on Aug 2, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
兼容新旧版本的接口路径
  • Loading branch information
sundy-li committed Jan 16, 2018
1 parent 00c9d05 commit 8663517
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Binary file modified questions.data
Binary file not shown.
8 changes: 4 additions & 4 deletions spider.go
Expand Up @@ -41,11 +41,11 @@ func (s *spider) Run(port string) {
func (s *spider) Init() {
requestHandleFunc := func(request *http.Request, ctx *goproxy.ProxyCtx) (req *http.Request, resp *http.Response) {
req = request
if ctx.Req.URL.Path == `/question/bat/findQuiz` {
if ctx.Req.URL.Path == `/question/bat/findQuiz` || ctx.Req.URL.Path == `/question/fight/findQuiz` {
bs, _ := ioutil.ReadAll(req.Body)
req.Body = ioutil.NopCloser(bytes.NewReader(bs))
handleQuestionReq(bs)
} else if ctx.Req.URL.Path == `/question/bat/choose` {
} else if ctx.Req.URL.Path == `/question/bat/choose` || ctx.Req.URL.Path == `/question/fight/choose` {
bs, _ := ioutil.ReadAll(req.Body)
req.Body = ioutil.NopCloser(bytes.NewReader(bs))
handleChooseReq(bs)
Expand All @@ -63,12 +63,12 @@ func (s *spider) Init() {
if resp == nil {
return resp
}
if ctx.Req.URL.Path == `/question/bat/findQuiz` {
if ctx.Req.URL.Path == `/question/bat/findQuiz` || ctx.Req.URL.Path == `/question/fight/findQuiz` {
bs, _ := ioutil.ReadAll(resp.Body)
bsNew := handleQuestionResp(bs)
resp.Body = ioutil.NopCloser(bytes.NewReader(bsNew))

} else if ctx.Req.URL.Path == `/question/bat/choose` {
} else if ctx.Req.URL.Path == `/question/bat/choose` || ctx.Req.URL.Path == `/question/fight/choose` {
bs, _ := ioutil.ReadAll(resp.Body)
resp.Body = ioutil.NopCloser(bytes.NewReader(bs))
go handleChooseResponse(bs)
Expand Down

1 comment on commit 8663517

@sundy-li
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.