~poldi1405/gomod-recter

v0.4.0 2 years ago .tar.gz browse log

fixed docker container

added:
	- version is now compiled in and appears at program start and in
	  response headers
	- 404 on go-get calls to unknown projects
	- CI Pipeline for automated builds
	- automatic test suite to verify the responses
fixed:
	- docker container should now really include the CA Certs, not
	  just a symlink to them
	- HEAD requests are now correctly processed

v0.3.1 2 years ago .tar.gz browse log

Docker Container now also comes with CA Certificates

This ensures that certificate validation can be left enabled when
running inside the prebuilt docker container.

v0.3.0 2 years ago .tar.gz browse log

added "go to definition" to godocs

This Version adds the possibility for documentation renderers to find
the sourcefile of a function. It also improves logging and deletes
sockets after terminating. The option to ignore certificates now
actually disables the validation of certificates.

v0.2.0 3 years ago .tar.gz browse log

tag v0.2.0
Tagger: Moritz Poldrack <ich@moritz-poldrack.de>
Date:   Thu Nov 25 00:38:50 2021 +0100

tag v0.2.0
Tagger: Moritz Poldrack <ich@moritz-poldrack.de>
Date:   Wed Nov 24 23:27:45 2021 +0100

asset handling, data fetching, and themes

added prepared themes
added automatic updates of packages
added asset handling

commit e28afde441d34fa10d78d91ba9a0b87ef990aac3
Author: Moritz Poldrack <ich@moritz-poldrack.de>
Date:   Wed Nov 24 23:27:21 2021 +0100

    added asset handling

diff --git a/internal/handler/assets.go b/internal/handler/assets.go
new file mode 100644
index 0000000..ff5be2e
--- /dev/null
+++ b/internal/handler/assets.go
@@ -0,0 +1,31 @@
+package handler
+
+import (
+	"io"
+	"mime"
+	"os"
+	"path"
+	"strings"
+
+	"git.sr.ht/~poldi1405/glog"
+	"github.com/spf13/viper"
+	"github.com/valyala/fasthttp"
+)
+
+func assetHandler(ctx *fasthttp.RequestCtx) {
+	filepath := viper.GetString("Directories.AssetDir") + strings.TrimPrefix(string(ctx.Path()), "/assets")
+
+	glog.Debugf("serving asset: %s", filepath)
+	fh, err := os.Open(filepath)
+	if err != nil {
+		ctx.SetStatusCode(fasthttp.StatusNotFound)
+		return
+	}
+	ctx.SetContentType(mime.TypeByExtension(path.Ext(filepath)))
+	_, err = io.Copy(ctx.Response.BodyWriter(), fh)
+	if err != nil {
+		ctx.SetStatusCode(fasthttp.StatusInternalServerError)
+		return
+	}
+	return
+}
diff --git a/internal/handler/handler.go b/internal/handler/handler.go
index be25afa..3a72e8d 100644
--- a/internal/handler/handler.go
+++ b/internal/handler/handler.go
@@ -30,12 +30,15 @@ func FasthttpHandler(ctx *fasthttp.RequestCtx) {
 		return
 	}

-	if name := viper.GetString("Projects." + string(path[1]) + ".Name"); name != "" {
+	name := viper.GetString("Projects." + string(path[1]) + ".Name")
+	switch {
+	case bytes.Compare(path[1], []byte("assets")) == 0:
+		assetHandler(ctx)
+	case name != "":
 		remainingPath := ctx.Path()[len(path[1])+1:]
 		projectHandler(ctx, string(path[1]), remainingPath)
-	} else {
+	default:
 		glog.Warnf("project '%s' not found in config", path[1])
-		ctx.SetStatusCode(fasthttp.StatusNotFound)
 		ctx.Redirect("/", fasthttp.StatusSeeOther)
 	}
 }

commit 132f4ca3600ccdb00fb3faa9b0b50ea7b1c7bf37
Author: Moritz Poldrack <ich@moritz-poldrack.de>
Date:   Wed Nov 24 23:27:21 2021 +0100

    added asset handling

diff --git a/internal/handler/assets.go b/internal/handler/assets.go
new file mode 100644
index 0000000..ff5be2e
--- /dev/null
+++ b/internal/handler/assets.go
@@ -0,0 +1,31 @@
+package handler
+
+import (
+	"io"
+	"mime"
+	"os"
+	"path"
+	"strings"
+
+	"git.sr.ht/~poldi1405/glog"
+	"github.com/spf13/viper"
+	"github.com/valyala/fasthttp"
+)
+
+func assetHandler(ctx *fasthttp.RequestCtx) {
+	filepath := viper.GetString("Directories.AssetDir") + strings.TrimPrefix(string(ctx.Path()), "/assets")
+
+	glog.Debugf("serving asset: %s", filepath)
+	fh, err := os.Open(filepath)
+	if err != nil {
+		ctx.SetStatusCode(fasthttp.StatusNotFound)
+		return
+	}
+	ctx.SetContentType(mime.TypeByExtension(path.Ext(filepath)))
+	_, err = io.Copy(ctx.Response.BodyWriter(), fh)
+	if err != nil {
+		ctx.SetStatusCode(fasthttp.StatusInternalServerError)
+		return
+	}
+	return
+}
diff --git a/internal/handler/handler.go b/internal/handler/handler.go
index be25afa..3a72e8d 100644
--- a/internal/handler/handler.go
+++ b/internal/handler/handler.go
@@ -30,12 +30,15 @@ func FasthttpHandler(ctx *fasthttp.RequestCtx) {
 		return
 	}

-	if name := viper.GetString("Projects." + string(path[1]) + ".Name"); name != "" {
+	name := viper.GetString("Projects." + string(path[1]) + ".Name")
+	switch {
+	case bytes.Compare(path[1], []byte("assets")) == 0:
+		assetHandler(ctx)
+	case name != "":
 		remainingPath := ctx.Path()[len(path[1])+1:]
 		projectHandler(ctx, string(path[1]), remainingPath)
-	} else {
+	default:
 		glog.Warnf("project '%s' not found in config", path[1])
-		ctx.SetStatusCode(fasthttp.StatusNotFound)
 		ctx.Redirect("/", fasthttp.StatusSeeOther)
 	}
 }

v0.1.0 3 years ago .tar.gz browse log

basic capabilities

Branches

master
5d550d85 — Moritz Poldrack 1 year, 10 months ago
rewrite
218184d8 — Moritz Poldrack 1 year, 10 months ago
wiki
1f35014a — Moritz Poldrack 2 years ago