~fwereade/pyjuju/related-units-watcher

« back to all changes in this revision

Viewing changes to store/server.go

  • Committer: Gustavo Niemeyer
  • Date: 2012-03-07 15:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: gustavo@niemeyer.net-20120307151713-t07dgpkcr1hap5xj
Applied review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
        }
71
71
        data, err := json.Marshal(response)
72
72
        if err == nil {
73
 
                w.Header()["Content-Type"] = []string{"application/json"}
 
73
                w.Header().Set("Content-Type", "application/json")
74
74
                _, err = w.Write(data)
75
75
        }
76
76
        if err != nil {
82
82
 
83
83
func (s *Server) serveCharm(w http.ResponseWriter, r *http.Request) {
84
84
        if !strings.HasPrefix(r.URL.Path, "/charm/") {
85
 
                w.WriteHeader(http.StatusNotFound)
86
 
                return
 
85
                panic("serveCharm: bad url")
87
86
        }
88
87
        curl, err := charm.ParseURL("cs:" + r.URL.Path[len("/charm/"):])
89
88
        if err != nil {
101
100
                return
102
101
        }
103
102
        defer rc.Close()
104
 
        w.Header()["Content-Type"] = []string{"application/octet-stream"}
 
103
        w.Header().Set("Content-Type", "application/octet-stream")
105
104
        _, err = io.Copy(w, rc)
106
105
        if err != nil {
107
106
                log.Printf("failed to stream charm %q: %v", curl, err)