forked from free-lancers/electricity_bill_calc_service
enhance(json):调整JSON编解码器的配置。
This commit is contained in:
@@ -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{
|
||||
|
Reference in New Issue
Block a user