aboutsummaryrefslogtreecommitdiff
path: root/server/file.go
diff options
context:
space:
mode:
authorLibravatar Terin Stock <terinjokes@gmail.com>2022-11-26 19:59:15 +0100
committerLibravatar Terin Stock <terinjokes@gmail.com>2022-11-26 23:51:25 +0100
commitf4ce6ac1be7b2817a8e02fc0e517d93ff9890d2e (patch)
tree9474949eb2a2f21e5276a72bd3acdb499c37b5a5 /server/file.go
parentinitial commit (diff)
downloadcgit-httpd-f4ce6ac1be7b2817a8e02fc0e517d93ff9890d2e.tar.xz
add initial version of cgit-httpd
Diffstat (limited to 'server/file.go')
-rw-r--r--server/file.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/server/file.go b/server/file.go
new file mode 100644
index 0000000..cdaef22
--- /dev/null
+++ b/server/file.go
@@ -0,0 +1,12 @@
+// Copyright 2022 Terin Stock.
+// SPDX-License-Identifier: MPL-2.0
+
+package server
+
+import "net/http"
+
+func FileHandler(path string) http.Handler {
+ return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
+ http.ServeFile(rw, req, path)
+ })
+}