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
Initial implementation of go-translate #1
Merged
+940
−0
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
63c8536
Add `dep init` and main.go files
yrliou 40bc6b7
Add Makefile
yrliou 58049eb
Add translate endpoint for translate requests
yrliou 0ebeb8d
Add translate tests
yrliou e1dde00
Add language endpoint for get language list requests
yrliou 711e789
Add language tests
yrliou 8ebc725
Add static resource handling
yrliou 7aed697
Add server tests
yrliou e1766c0
Add README.md
yrliou d8129d4
dep update
yrliou 1cf4eaf
Update brave proxy addresses to production
yrliou 81590b7
Fix missing returns in error cases
yrliou f6c165b
Migrate from `dep` to go modules
yrliou 2c154d7
Update README.md for migration from dep to go modules
yrliou File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Fix missing returns in error cases
- Loading branch information
| @@ -67,6 +67,7 @@ func GetLanguageList(w http.ResponseWriter, r *http.Request) { | ||
| req, err := http.NewRequest("GET", MSTranslateServer+languageEndpoint, nil) | ||
|
This conversation was marked as resolved
by yrliou
evq
Member
|
||
| if err != nil { | ||
| http.Error(w, fmt.Sprintf("Error creating MS request: %v", err), http.StatusInternalServerError) | ||
|
This conversation was marked as resolved
by yrliou
|
||
| return | ||
| } | ||
|
|
||
| client := getHTTPClient() | ||
| @@ -99,6 +100,7 @@ func GetLanguageList(w http.ResponseWriter, r *http.Request) { | ||
| msBody, err := ioutil.ReadAll(msResp.Body) | ||
| if err != nil { | ||
| http.Error(w, fmt.Sprintf("Error reading MS response body: %v", err), http.StatusInternalServerError) | ||
| return | ||
| } | ||
| body, err := language.ToGoogleLanguageList(msBody) | ||
| if err != nil { | ||
| @@ -154,6 +156,7 @@ func Translate(w http.ResponseWriter, r *http.Request) { | ||
| msBody, err := ioutil.ReadAll(msResp.Body) | ||
| if err != nil { | ||
| http.Error(w, fmt.Sprintf("Error reading MS response body: %v", err), http.StatusInternalServerError) | ||
| return | ||
| } | ||
| body, err := translate.ToGoogleResponseBody(msBody, isAuto) | ||
| if err != nil { | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
We unset the X-Forwarded-* headers sent to Google servers at the proxy. We should unset the headers for connection to Microsoft servers as well. See: https://github.com/brave/devops/pull/785/files#diff-e262328707cf31665d8378e0949ef286R67