Switch to using jsoniter
This commit is contained in:
parent
5a94b7a588
commit
0395b2024d
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
2
go.mod
2
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
|
||||
|
|
6
main.go
6
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":
|
||||
|
|
Loading…
Reference in New Issue