| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Package som implements HTTP server that handles requests to default module. | 5 // Package som implements HTTP server that handles requests to default module. |
| 6 package som | 6 package som |
| 7 | 7 |
| 8 import ( | 8 import ( |
| 9 "crypto/sha1" | 9 "crypto/sha1" |
| 10 "encoding/json" | 10 "encoding/json" |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 if err != nil { | 499 if err != nil { |
| 500 errStatus(w, http.StatusInternalServerError, err.Error()) | 500 errStatus(w, http.StatusInternalServerError, err.Error()) |
| 501 return | 501 return |
| 502 } | 502 } |
| 503 | 503 |
| 504 w.Header().Set("Content-Type", "application/json") | 504 w.Header().Set("Content-Type", "application/json") |
| 505 w.Write(bytes) | 505 w.Write(bytes) |
| 506 } | 506 } |
| 507 | 507 |
| 508 func getCrRevJSON(c context.Context, pos string) (map[string]string, error) { | 508 func getCrRevJSON(c context.Context, pos string) (map[string]string, error) { |
| 509 » c = client.UseServiceAccountTransport(c, nil, nil) | 509 » c = client.UseServiceAccountTransport(c, nil) |
| 510 | 510 |
| 511 hc := &http.Client{Transport: urlfetch.Get(c)} | 511 hc := &http.Client{Transport: urlfetch.Get(c)} |
| 512 | 512 |
| 513 resp, err := hc.Get(fmt.Sprintf("https://cr-rev.appspot.com/_ah/api/crre
v/v1/redirect/%s", pos)) | 513 resp, err := hc.Get(fmt.Sprintf("https://cr-rev.appspot.com/_ah/api/crre
v/v1/redirect/%s", pos)) |
| 514 if err != nil { | 514 if err != nil { |
| 515 return nil, err | 515 return nil, err |
| 516 } | 516 } |
| 517 | 517 |
| 518 defer resp.Body.Close() | 518 defer resp.Body.Close() |
| 519 body, err := ioutil.ReadAll(resp.Body) | 519 body, err := ioutil.ReadAll(resp.Body) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 rootRouter.GET("/*path", authmw, indexPage) | 594 rootRouter.GET("/*path", authmw, indexPage) |
| 595 | 595 |
| 596 http.DefaultServeMux.Handle("/api/", r) | 596 http.DefaultServeMux.Handle("/api/", r) |
| 597 http.DefaultServeMux.Handle("/admin/", r) | 597 http.DefaultServeMux.Handle("/admin/", r) |
| 598 http.DefaultServeMux.Handle("/auth/", r) | 598 http.DefaultServeMux.Handle("/auth/", r) |
| 599 http.DefaultServeMux.Handle("/_ah/", r) | 599 http.DefaultServeMux.Handle("/_ah/", r) |
| 600 http.DefaultServeMux.Handle("/internal/", r) | 600 http.DefaultServeMux.Handle("/internal/", r) |
| 601 | 601 |
| 602 http.DefaultServeMux.Handle("/", rootRouter) | 602 http.DefaultServeMux.Handle("/", rootRouter) |
| 603 } | 603 } |
| OLD | NEW |