Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Unified Diff: sky/tools/skygo/sky_server.go

Issue 746373002: Convert sky_server over to a go-based http server. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address review comments Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/tools/skygo/README ('k') | sky/tools/skygo/sky_server.sha1 » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/tools/skygo/sky_server.go
diff --git a/sky/tools/skygo/sky_server.go b/sky/tools/skygo/sky_server.go
new file mode 100644
index 0000000000000000000000000000000000000000..c69fdd520420ddb5f3bc1db3d9a153bf90331fde
--- /dev/null
+++ b/sky/tools/skygo/sky_server.go
@@ -0,0 +1,46 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package main
+
+import (
+ "flag"
+ "net/http"
+ "path"
+ "strings"
+)
+
+type skyHandlerRoot struct {
+ root string
+}
+
+func skyHandler(root string) http.Handler {
+ return &skyHandlerRoot{root}
+}
+
+func (handler *skyHandlerRoot) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ path := path.Join(handler.root, r.URL.Path)
+ if strings.HasSuffix(path, ".sky") {
+ w.Header().Set("Content-Type", "text/sky")
+ }
+ http.ServeFile(w, r, path)
+}
+
+func main() {
+ var configuration = flag.String("t", "Release", "The target configuration (i.e. Release or Debug)")
+ flag.Parse()
+
+ args := flag.Args()
+ root := args[0]
+ port := args[1]
+
+ genRoot := path.Join(root, "out", *configuration, "gen")
+
+ http.Handle("/", skyHandler(root))
+ http.Handle("/mojo/public/", http.StripPrefix("/mojo/public/", skyHandler(path.Join(genRoot, "mojo", "public"))))
+ http.Handle("/mojo/services/", http.StripPrefix("/mojo/services/", skyHandler(path.Join(genRoot, "mojo", "services"))))
+ http.Handle("/sky/services/", http.StripPrefix("/sky/services/", skyHandler(path.Join(genRoot, "sky", "services"))))
+
+ http.ListenAndServe(":" + port, nil)
+}
« no previous file with comments | « sky/tools/skygo/README ('k') | sky/tools/skygo/sky_server.sha1 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698