aboutsummaryrefslogtreecommitdiff
path: root/http_handle_repo_raw.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--http_handle_repo_raw.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/http_handle_repo_raw.go b/http_handle_repo_raw.go
index 7d25071..ba67ac1 100644
--- a/http_handle_repo_raw.go
+++ b/http_handle_repo_raw.go
@@ -1,8 +1,8 @@
package main
import (
- "fmt"
"errors"
+ "fmt"
"net/http"
"path"
"strings"
@@ -19,7 +19,7 @@ func handle_repo_raw(w http.ResponseWriter, r *http.Request, params map[string]a
if errors.Is(err, err_no_ref_spec) {
ref_type = "head"
} else {
- fmt.Fprintln(w, "Error querying ref type:", err.Error())
+ http.Error(w, "Error querying ref type:: "+err.Error(), http.StatusInternalServerError)
return
}
}
@@ -28,25 +28,25 @@ func handle_repo_raw(w http.ResponseWriter, r *http.Request, params map[string]a
repo, description, err := open_git_repo(r.Context(), group_name, repo_name)
if err != nil {
- fmt.Fprintln(w, "Error opening repo:", err.Error())
+ http.Error(w, "Error opening repo:: "+err.Error(), http.StatusInternalServerError)
return
}
params["repo_description"] = description
ref_hash, err := get_ref_hash_from_type_and_name(repo, ref_type, ref_name)
if err != nil {
- fmt.Fprintln(w, "Error getting ref hash:", err.Error())
+ http.Error(w, "Error getting ref hash:: "+err.Error(), http.StatusInternalServerError)
return
}
commit_object, err := repo.CommitObject(ref_hash)
if err != nil {
- fmt.Fprintln(w, "Error getting commit object:", err.Error())
+ http.Error(w, "Error getting commit object:: "+err.Error(), http.StatusInternalServerError)
return
}
tree, err := commit_object.Tree()
if err != nil {
- fmt.Fprintln(w, "Error getting file tree:", err.Error())
+ http.Error(w, "Error getting file tree:: "+err.Error(), http.StatusInternalServerError)
return
}
@@ -58,7 +58,7 @@ func handle_repo_raw(w http.ResponseWriter, r *http.Request, params map[string]a
if err != nil {
file, err := tree.File(path_spec)
if err != nil {
- fmt.Fprintln(w, "Error retrieving path:", err.Error())
+ http.Error(w, "Error retrieving path:: "+err.Error(), http.StatusInternalServerError)
return
}
if len(raw_path_spec) != 0 && raw_path_spec[len(raw_path_spec)-1] == '/' {
@@ -67,7 +67,7 @@ func handle_repo_raw(w http.ResponseWriter, r *http.Request, params map[string]a
}
file_contents, err := file.Contents()
if err != nil {
- fmt.Fprintln(w, "Error reading file:", err.Error())
+ http.Error(w, "Error reading file:: "+err.Error(), http.StatusInternalServerError)
return
}
fmt.Fprintln(w, file_contents)
@@ -84,7 +84,7 @@ func handle_repo_raw(w http.ResponseWriter, r *http.Request, params map[string]a
err = templates.ExecuteTemplate(w, "repo_raw_dir", params)
if err != nil {
- fmt.Fprintln(w, "Error rendering template:", err.Error())
+ http.Error(w, "Error rendering template:: "+err.Error(), http.StatusInternalServerError)
return
}
}