From a1b5ab3705b7d80405b5185f97dbcb80836504e1 Mon Sep 17 00:00:00 2001 From: Moritz Poldrack Date: Thu, 9 Dec 2021 19:54:05 +0100 Subject: [PATCH] fixed converting to normal internal packages --- Makefile | 2 +- config.go | 4 ++-- internal/handler/api.go | 26 +++++++++++++------------- internal/handler/index.go | 2 +- internal/handler/project.go | 2 +- internal/handler/templateHelper.go | 3 ++- main.go | 2 +- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 3cf0b80..7ffa3a4 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ OUTFILE?=recter$(GOEXE) CGO_ENABLED?=0 build: - go build $(GOTAGS) -o "$(OUTFILE)" -v -trimpath -modcacherw -mod=readonly -ldflags="-s -w -extldflags=-static -X main.Version=$(VERSION)" + go build $(GOTAGS) -o "$(OUTFILE)" -v -trimpath -modcacherw -mod=readonly -ldflags="-s -w -X main.Version=$(VERSION)" IMAGENAME=recter REPO=mpldr diff --git a/config.go b/config.go index 1bc0e81..1f7daf5 100644 --- a/config.go +++ b/config.go @@ -5,8 +5,8 @@ import ( "sync" "time" - "internal/data" - "internal/data/worker" + "mpldr.codes/recter/internal/data" + "mpldr.codes/recter/internal/data/worker" "git.sr.ht/~poldi1405/glog" "github.com/fsnotify/fsnotify" diff --git a/internal/handler/api.go b/internal/handler/api.go index 546c069..37b1aa0 100644 --- a/internal/handler/api.go +++ b/internal/handler/api.go @@ -3,7 +3,7 @@ package handler import ( "encoding/json" - "internal/data" + "mpldr.codes/recter/internal/data" "git.sr.ht/~poldi1405/glog" "github.com/valyala/fasthttp" @@ -11,18 +11,18 @@ import ( func apiHandler(ctx *fasthttp.RequestCtx, proj *data.Project, remainingPath []byte) { ctx.SetContentTypeBytes([]byte("application/json")) - glog.Tracef("remainder: %s",remainingPath) + glog.Tracef("remainder: %s", remainingPath) switch string(remainingPath) { case "/versions": - response, _ := json.Marshal(proj.Versions) - ctx.Write(response) + response, _ := json.Marshal(proj.Versions) + ctx.Write(response) case "/versions/latest": - response, _ := json.Marshal(getLatestVersion(proj)) - ctx.Write(response) + response, _ := json.Marshal(getLatestVersion(proj)) + ctx.Write(response) case "/details": - response, _ := json.Marshal(proj) - ctx.Write(response) + response, _ := json.Marshal(proj) + ctx.Write(response) default: api404Handler(ctx) } @@ -32,12 +32,12 @@ func api404Handler(ctx *fasthttp.RequestCtx) { ctx.SetStatusCode(fasthttp.StatusNotFound) type response404 struct { - Message string `json:"message"` + Message string `json:"message"` AvailableEndpoints []string `json:"allowed_endpoints"` } response, _ := json.Marshal(response404{ - Message: "requested API endpoint was not found", - AvailableEndpoints: []string{"/versions","/versions/latest","/details"}, + Message: "requested API endpoint was not found", + AvailableEndpoints: []string{"/versions", "/versions/latest", "/details"}, }) ctx.Write(response) } @@ -53,5 +53,5 @@ func getLatestVersion(proj *data.Project) *latestVersion { lv = proj.Versions[0] } - return &latestVersion{V:lv} -} \ No newline at end of file + return &latestVersion{V: lv} +} diff --git a/internal/handler/index.go b/internal/handler/index.go index fd044d2..fc61bed 100644 --- a/internal/handler/index.go +++ b/internal/handler/index.go @@ -6,7 +6,7 @@ import ( "git.sr.ht/~poldi1405/glog" "github.com/spf13/viper" "github.com/valyala/fasthttp" - "internal/data" + "mpldr.codes/recter/internal/data" ) func indexHandler(ctx *fasthttp.RequestCtx) { diff --git a/internal/handler/project.go b/internal/handler/project.go index a519e5c..06cd069 100644 --- a/internal/handler/project.go +++ b/internal/handler/project.go @@ -4,7 +4,7 @@ import ( "bytes" "fmt" - "internal/data" + "mpldr.codes/recter/internal/data" "git.sr.ht/~poldi1405/glog" "github.com/spf13/viper" diff --git a/internal/handler/templateHelper.go b/internal/handler/templateHelper.go index 2aca565..9911af0 100644 --- a/internal/handler/templateHelper.go +++ b/internal/handler/templateHelper.go @@ -3,7 +3,8 @@ package handler import ( "fmt" "html/template" - "internal/data" + + "mpldr.codes/recter/internal/data" ) func getTemplateWithHelper(proj *data.Project) *template.Template { diff --git a/main.go b/main.go index 5b83b38..85e14be 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,7 @@ import ( "net" "os" - "internal/handler" + "mpldr.codes/recter/internal/handler" "git.sr.ht/~poldi1405/glog" "github.com/spf13/viper" -- 2.45.2