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

Side by Side Diff: sky/tools/skygo/sky_server.go

Issue 1091163003: Make sky_server include no-cache headers since we don't really want caching during development. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | sky/tools/skygo/sky_server.sha1 » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "fmt" 9 "fmt"
10 "io/ioutil" 10 "io/ioutil"
(...skipping 10 matching lines...) Expand all
21 21
22 func skyHandler(root string) http.Handler { 22 func skyHandler(root string) http.Handler {
23 return &skyHandlerRoot{root} 23 return &skyHandlerRoot{root}
24 } 24 }
25 25
26 func (handler *skyHandlerRoot) ServeHTTP(w http.ResponseWriter, r *http.Request) { 26 func (handler *skyHandlerRoot) ServeHTTP(w http.ResponseWriter, r *http.Request) {
27 path := path.Join(handler.root, r.URL.Path) 27 path := path.Join(handler.root, r.URL.Path)
28 if strings.HasSuffix(path, ".sky") { 28 if strings.HasSuffix(path, ".sky") {
29 w.Header().Set("Content-Type", "text/sky") 29 w.Header().Set("Content-Type", "text/sky")
30 } 30 }
31 w.Header().Set("Cache-Control", "no-cache")
31 http.ServeFile(w, r, path) 32 http.ServeFile(w, r, path)
32 } 33 }
33 34
34 func usage() { 35 func usage() {
35 fmt.Fprintf(os.Stderr, "Usage: sky_server [flags] MOJO_SRC_ROOT PORT\n\n") 36 fmt.Fprintf(os.Stderr, "Usage: sky_server [flags] MOJO_SRC_ROOT PORT\n\n")
36 fmt.Fprintf(os.Stderr, "launches a basic http server with mappings into the\ n") 37 fmt.Fprintf(os.Stderr, "launches a basic http server with mappings into the\ n")
37 fmt.Fprintf(os.Stderr, "mojo repository for framework/service paths.\n") 38 fmt.Fprintf(os.Stderr, "mojo repository for framework/service paths.\n")
38 fmt.Fprintf(os.Stderr, "[flags] MUST be before arguments, because go:flag.\n \n") 39 fmt.Fprintf(os.Stderr, "[flags] MUST be before arguments, because go:flag.\n \n")
39 flag.PrintDefaults() 40 flag.PrintDefaults()
40 os.Exit(2) 41 os.Exit(2)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 defer r.Body.Close() 78 defer r.Body.Close()
78 body, _ := ioutil.ReadAll(r.Body) 79 body, _ := ioutil.ReadAll(r.Body)
79 w.Write(body) 80 w.Write(body)
80 }) 81 })
81 82
82 addMapping("/gen/", genRoot) 83 addMapping("/gen/", genRoot)
83 addMapping("/packages/", packageRoot) 84 addMapping("/packages/", packageRoot)
84 85
85 http.ListenAndServe(":" + port, nil) 86 http.ListenAndServe(":" + port, nil)
86 } 87 }
OLDNEW
« no previous file with comments | « no previous file | sky/tools/skygo/sky_server.sha1 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698