diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-06 09:26:46 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-06 09:27:53 +0800 |
commit | da1d8f4e7c332c7109427915e6459b10209cedce (patch) | |
tree | 280b921be3b51f93d82d916b4eaa89387b7102cc /internal/unsorted/http_handle_repo_raw.go | |
parent | git2c, git2d: Rename cmd1 and cmd2 descriptively (diff) | |
download | forge-da1d8f4e7c332c7109427915e6459b10209cedce.tar.gz forge-da1d8f4e7c332c7109427915e6459b10209cedce.tar.zst forge-da1d8f4e7c332c7109427915e6459b10209cedce.zip |
Move the Go stuff to ./forged/v0.1.32
Diffstat (limited to 'internal/unsorted/http_handle_repo_raw.go')
-rw-r--r-- | internal/unsorted/http_handle_repo_raw.go | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/internal/unsorted/http_handle_repo_raw.go b/internal/unsorted/http_handle_repo_raw.go deleted file mode 100644 index 3d999e5..0000000 --- a/internal/unsorted/http_handle_repo_raw.go +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only -// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> - -package unsorted - -import ( - "fmt" - "html/template" - "net/http" - "strings" - - "go.lindenii.runxiyu.org/forge/internal/git2c" - "go.lindenii.runxiyu.org/forge/internal/misc" - "go.lindenii.runxiyu.org/forge/internal/web" -) - -// httpHandleRepoRaw serves raw files, or directory listings that point to raw -// files. -func (s *Server) httpHandleRepoRaw(writer http.ResponseWriter, request *http.Request, params map[string]any) { - repoName := params["repo_name"].(string) - groupPath := params["group_path"].([]string) - rawPathSpec := params["rest"].(string) - pathSpec := strings.TrimSuffix(rawPathSpec, "/") - params["path_spec"] = pathSpec - - _, repoPath, _, _, _, _, _ := s.getRepoInfo(request.Context(), groupPath, repoName, "") - - client, err := git2c.NewClient(s.config.Git.Socket) - if err != nil { - web.ErrorPage500(s.templates, writer, params, err.Error()) - return - } - defer client.Close() - - files, content, err := client.CmdTreeRaw(repoPath, pathSpec) - if err != nil { - web.ErrorPage500(s.templates, writer, params, err.Error()) - return - } - - switch { - case files != nil: - params["files"] = files - params["readme_filename"] = "README.md" - params["readme"] = template.HTML("<p>README rendering here is WIP again</p>") // TODO - s.renderTemplate(writer, "repo_raw_dir", params) - case content != "": - if misc.RedirectNoDir(writer, request) { - return - } - writer.Header().Set("Content-Type", "application/octet-stream") - fmt.Fprint(writer, content) - default: - web.ErrorPage500(s.templates, writer, params, "Unknown error fetching repo raw data") - } -} |