enhance(json):调整JSON编解码器的配置。
This commit is contained in:
parent
00e2664007
commit
11cc6f0de1
6
main.go
6
main.go
|
@ -17,7 +17,6 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
jsontime "github.com/liamylian/jsontime/v2/v2"
|
||||
"github.com/samber/lo"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/uptrace/bun/migrate"
|
||||
|
@ -70,11 +69,6 @@ func init() {
|
|||
l.Fatal("Singularity account intialize failed.", zap.Error(err))
|
||||
}
|
||||
l.Info("Singularity account intialized.")
|
||||
|
||||
timeZoneShanghai, _ := time.LoadLocation("Asia/Shanghai")
|
||||
jsontime.AddTimeFormatAlias("simple_datetime", "2006-01-02 15:04:05")
|
||||
jsontime.AddTimeFormatAlias("simple_date", "2006-01-02")
|
||||
jsontime.AddLocaleAlias("shanghai", timeZoneShanghai)
|
||||
}
|
||||
|
||||
func initializeRegions() error {
|
||||
|
|
|
@ -6,13 +6,24 @@ import (
|
|||
"electricity_bill_calc/security"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/compress"
|
||||
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||
jsontime "github.com/liamylian/jsontime/v2/v2"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var json = jsontime.ConfigWithCustomTimeFormat
|
||||
|
||||
func init() {
|
||||
timeZoneShanghai, _ := time.LoadLocation("Asia/Shanghai")
|
||||
jsontime.AddTimeFormatAlias("simple_datetime", "2006-01-02 15:04:05")
|
||||
jsontime.AddTimeFormatAlias("simple_date", "2006-01-02")
|
||||
jsontime.AddLocaleAlias("shanghai", timeZoneShanghai)
|
||||
}
|
||||
|
||||
func App() *fiber.App {
|
||||
app := fiber.New(fiber.Config{
|
||||
BodyLimit: 10 * 1024 * 1024,
|
||||
|
@ -20,6 +31,8 @@ func App() *fiber.App {
|
|||
EnableTrustedProxyCheck: false,
|
||||
Prefork: false,
|
||||
ErrorHandler: errorHandler,
|
||||
JSONEncoder: json.Marshal,
|
||||
JSONDecoder: json.Unmarshal,
|
||||
})
|
||||
app.Use(compress.New())
|
||||
app.Use(recover.New(recover.Config{
|
||||
|
|
Loading…
Reference in New Issue
Block a user