| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 main | 5 package main |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "flag" | 8 "flag" |
| 9 "io/ioutil" | |
| 10 "net/http" | 9 "net/http" |
| 11 "path" | 10 "path" |
| 12 "strings" | 11 "strings" |
| 13 ) | 12 ) |
| 14 | 13 |
| 15 type skyHandlerRoot struct { | 14 type skyHandlerRoot struct { |
| 16 root string | 15 root string |
| 17 } | 16 } |
| 18 | 17 |
| 19 func skyHandler(root string) http.Handler { | 18 func skyHandler(root string) http.Handler { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 32 var configuration = flag.String("t", "Release", "The target configuration (i
.e. Release or Debug)") | 31 var configuration = flag.String("t", "Release", "The target configuration (i
.e. Release or Debug)") |
| 33 flag.Parse() | 32 flag.Parse() |
| 34 | 33 |
| 35 args := flag.Args() | 34 args := flag.Args() |
| 36 root := args[0] | 35 root := args[0] |
| 37 port := args[1] | 36 port := args[1] |
| 38 | 37 |
| 39 genRoot := path.Join(root, "out", *configuration, "gen") | 38 genRoot := path.Join(root, "out", *configuration, "gen") |
| 40 | 39 |
| 41 http.Handle("/", skyHandler(root)) | 40 http.Handle("/", skyHandler(root)) |
| 42 http.HandleFunc("/echo_post", func(w http.ResponseWriter, r *http.Request) { | |
| 43 defer r.Body.Close() | |
| 44 body, _ := ioutil.ReadAll(r.Body) | |
| 45 w.Write(body) | |
| 46 }) | |
| 47 http.Handle("/mojo/public/", http.StripPrefix("/mojo/public/", skyHandler(pa
th.Join(genRoot, "mojo", "public")))) | 41 http.Handle("/mojo/public/", http.StripPrefix("/mojo/public/", skyHandler(pa
th.Join(genRoot, "mojo", "public")))) |
| 48 http.Handle("/mojo/services/", http.StripPrefix("/mojo/services/", skyHandle
r(path.Join(genRoot, "mojo", "services")))) | 42 http.Handle("/mojo/services/", http.StripPrefix("/mojo/services/", skyHandle
r(path.Join(genRoot, "mojo", "services")))) |
| 49 http.Handle("/sky/services/", http.StripPrefix("/sky/services/", skyHandler(
path.Join(genRoot, "sky", "services")))) | 43 http.Handle("/sky/services/", http.StripPrefix("/sky/services/", skyHandler(
path.Join(genRoot, "sky", "services")))) |
| 50 | 44 |
| 51 http.ListenAndServe(":" + port, nil) | 45 http.ListenAndServe(":" + port, nil) |
| 52 } | 46 } |
| OLD | NEW |