Skip to content

Commit

Permalink
Refactor analyzeCommand()
Browse files Browse the repository at this point in the history
  • Loading branch information
nowsprinting committed Oct 26, 2016
1 parent c72eaa0 commit dd04337
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 14 additions & 3 deletions analyze_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"net/http"

"golang.org/x/net/context"

"github.com/line/line-bot-sdk-go/linebot"

"google.golang.org/appengine"
Expand All @@ -12,10 +14,11 @@ import (

/**
* コマンド解析
*
* 引数にContextとhttp.Clientを取るインナーメソッド
*/
func analyzeCommand(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
bot, err := createBotClient(c, urlfetch.Client(c))
func analyzeCommandWithContext(c context.Context, client *http.Client, w http.ResponseWriter, r *http.Request) {
bot, err := createBotClient(c, client)
if err != nil {
return
}
Expand All @@ -29,3 +32,11 @@ func analyzeCommand(w http.ResponseWriter, r *http.Request) {
log.Errorf(c, "Error occurred at reply-message for command. mid:%v, err: %v", mid, err)
}
}

/**
* コマンド解析
*/
func analyzeCommand(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
analyzeCommandWithContext(c, urlfetch.Client(c), w, r)
}
2 changes: 2 additions & 0 deletions leave.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (

/**
* 友だち削除(データストアから削除)
*
* 引数にContextとhttp.Clientを取るインナーメソッド
*/
func leaveWithContext(c context.Context, client *http.Client, w http.ResponseWriter, r *http.Request) {
bot, err := createBotClient(c, client)
Expand Down

0 comments on commit dd04337

Please sign in to comment.