~poldi1405/gomod-recter

a1b5ab3705b7d80405b5185f97dbcb80836504e1 — Moritz Poldrack 2 years ago e17ead3
fixed converting to normal internal packages
M Makefile => Makefile +1 -1
@@ 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

M config.go => config.go +2 -2
@@ 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"

M internal/handler/api.go => internal/handler/api.go +13 -13
@@ 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}
}

M internal/handler/index.go => internal/handler/index.go +1 -1
@@ 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) {

M internal/handler/project.go => internal/handler/project.go +1 -1
@@ 4,7 4,7 @@ import (
	"bytes"
	"fmt"

	"internal/data"
	"mpldr.codes/recter/internal/data"

	"git.sr.ht/~poldi1405/glog"
	"github.com/spf13/viper"

M internal/handler/templateHelper.go => internal/handler/templateHelper.go +2 -1
@@ 3,7 3,8 @@ package handler
import (
	"fmt"
	"html/template"
	"internal/data"

	"mpldr.codes/recter/internal/data"
)

func getTemplateWithHelper(proj *data.Project) *template.Template {

M main.go => main.go +1 -1
@@ 4,7 4,7 @@ import (
	"net"
	"os"

	"internal/handler"
	"mpldr.codes/recter/internal/handler"

	"git.sr.ht/~poldi1405/glog"
	"github.com/spf13/viper"