Skip to content

Commit

Permalink
modify params
Browse files Browse the repository at this point in the history
  • Loading branch information
chenqinghe committed Dec 1, 2017
1 parent 9bd9bd5 commit 74df04f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package internal

import (
"errors"

"github.com/imroc/req"
)

Expand Down Expand Up @@ -37,8 +38,9 @@ type Authorizer interface {
Authorize(client *Client) error
}

type DefaultAuthorizer struct {
}
type DefaultAuthorizer struct{}

type RestApiAuthorizer DefaultAuthorizer

func (da DefaultAuthorizer) Authorize(client *Client) error {
resp, err := req.Post(VOICE_AUTH_URL, req.Param{
Expand Down
9 changes: 5 additions & 4 deletions ocr/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ocr

import (
"encoding/base64"

sdk "github.com/chenqinghe/baidu-ai-go-sdk/internal"
"github.com/imroc/req"
)
Expand Down Expand Up @@ -96,12 +97,12 @@ func (oc *OCRClient) GeneralRecognizeEnhanced(img []byte, conf map[string]string
}

func parseParams(def, need map[string]string) map[string]string {
for key, value := range def {
if _, ok := need[key]; !ok {
need[key] = value
for key, _ := range def {
if val, ok := need[key]; ok {
def[key] = val
}
}
return need
return def
}

func doRequest(url string, params map[string]string) (rs []byte, err error) {
Expand Down

0 comments on commit 74df04f

Please sign in to comment.