Merge pull request #864 from Bugagazavr/json_response

Response as JSON instead plain text
This commit is contained in:
Brad Rydzewski 2015-02-01 23:41:02 -08:00
commit 22fa37c3f1
4 changed files with 7 additions and 0 deletions

View file

@ -113,6 +113,8 @@ func GetCC(c web.C, w http.ResponseWriter, r *http.Request) {
name = c.URLParams["name"]
)
w.Header().Set("Content-Type", "application/xml")
repo, err := datastore.GetRepoName(ctx, host, owner, name)
if err != nil {
w.WriteHeader(http.StatusNotFound)

View file

@ -30,6 +30,8 @@ func GetLogin(c web.C, w http.ResponseWriter, r *http.Request) {
return
}
w.Header().Del("Content-Type")
// authenticate the user
login, err := remote.Authorize(w, r)
if err != nil {

View file

@ -24,6 +24,8 @@ func GetOutput(c web.C, w http.ResponseWriter, r *http.Request) {
hash = c.URLParams["commit"]
)
w.Header().Set("Content-Type", "text/plain")
path := filepath.Join(host, owner, name, branch, hash)
rc, err := blobstore.GetReader(ctx, path)
if err != nil {

View file

@ -15,6 +15,7 @@ func Options(c *web.C, h http.Handler) http.Handler {
w.Header().Set("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Authorization")
w.Header().Set("Allow", "HEAD,GET,POST,PUT,DELETE,OPTIONS")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
return
}