diff --git a/Dockerfile b/Dockerfile index 26fb14a..6a5085d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN go mod download COPY main.go . # Build the application -RUN go build -o main . +RUN go build -tags=jsoniter -o main . # Move to /dist directory as the place for resulting binary folder WORKDIR /dist diff --git a/flake.nix b/flake.nix index c02d16f..55a35ad 100644 --- a/flake.nix +++ b/flake.nix @@ -40,6 +40,8 @@ src = self; vendorSha256 = "sha256-KUgKselGjYI0I1zT/LB48pksswNXLbrgBM6LtYPeT/Q="; + tags = [ "jsoniter" ]; + postInstall = '' mkdir -p $out/usr/lib/ifconfig.io/ cp -r ./templates $out/usr/lib/ifconfig.io diff --git a/go.mod b/go.mod index 6bdbc52..f560b00 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/gin-gonic/gin v1.7.7 github.com/go-playground/validator/v10 v10.10.0 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/json-iterator/go v1.1.12 // indirect + github.com/json-iterator/go v1.1.12 github.com/leodido/go-urn v1.2.1 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect diff --git a/main.go b/main.go index 9263806..6e10228 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "fmt" "net" "os" @@ -9,6 +8,8 @@ import ( "strings" "time" + json "github.com/json-iterator/go" + "github.com/gin-gonic/gin" proxyproto "github.com/pires/go-proxyproto" ) @@ -153,7 +154,8 @@ func mainHandler(c *gin.Context) { response, _ := json.Marshal(c.Keys) c.String(200, "ifconfig_io = %v\n", string(response)) } else { - c.String(200, "%v", c.Keys) + c.Writer.Header().Set("Content-Type", "text/plain; charset=utf-8") + c.YAML(200, c.Keys) } return case "headers":