Skip to content

Commit 9615dd5

Browse files
committed
updated fiber
1 parent c349897 commit 9615dd5

File tree

3 files changed

+59
-16
lines changed

3 files changed

+59
-16
lines changed

endpoints/subscription.endpoint.go

+33-9
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ func (subscriptionEndpoint *SubscriptionEndpoint) Subscribe(ctx *fiber.Ctx) erro
3535
"message": err.Error(),
3636
})
3737
}
38-
return ctx.JSON(subscription)
38+
marshalled, _ := json.Marshal(subscription)
39+
var payload interface{}
40+
json.Unmarshal(marshalled, &payload)
41+
return ctx.JSON(payload)
3942
}
4043

4144
// GetCustomer function
@@ -52,7 +55,10 @@ func (subscriptionEndpoint *SubscriptionEndpoint) GetCustomer(ctx *fiber.Ctx) er
5255
"message": err.Error(),
5356
})
5457
}
55-
return ctx.JSON(sCustomer)
58+
marshalled, _ := json.Marshal(sCustomer)
59+
var payload interface{}
60+
json.Unmarshal(marshalled, &payload)
61+
return ctx.Status(200).JSON(payload)
5662
}
5763

5864
// GetCustomerInvoices function
@@ -70,7 +76,10 @@ func (subscriptionEndpoint *SubscriptionEndpoint) GetCustomerInvoices(ctx *fiber
7076
if len(sCustomerInvoices) == 0 {
7177
return ctx.JSON([]string{})
7278
}
73-
return ctx.JSON(sCustomerInvoices)
79+
marshalled, _ := json.Marshal(sCustomerInvoices)
80+
var payload interface{}
81+
json.Unmarshal(marshalled, &payload)
82+
return ctx.Status(200).JSON(payload)
7483
}
7584

7685
// GetCustomerCards function
@@ -88,7 +97,10 @@ func (subscriptionEndpoint *SubscriptionEndpoint) GetCustomerCards(ctx *fiber.Ct
8897
if len(sCustomerCards) == 0 {
8998
return ctx.JSON([]string{})
9099
}
91-
return ctx.JSON(sCustomerCards)
100+
marshalled, _ := json.Marshal(sCustomerCards)
101+
var payload interface{}
102+
json.Unmarshal(marshalled, &payload)
103+
return ctx.Status(200).JSON(payload)
92104
}
93105

94106
// CancelSubscription function
@@ -115,7 +127,10 @@ func (subscriptionEndpoint *SubscriptionEndpoint) CancelSubscription(ctx *fiber.
115127
"message": err.Error(),
116128
})
117129
}
118-
return ctx.JSON(sCustomer)
130+
marshalled, _ := json.Marshal(sCustomer)
131+
var payload interface{}
132+
json.Unmarshal(marshalled, &payload)
133+
return ctx.Status(200).JSON(payload)
119134
}
120135

121136
// AddCreditCard function
@@ -133,7 +148,10 @@ func (subscriptionEndpoint *SubscriptionEndpoint) CreateSetupIntent(ctx *fiber.C
133148
"message": err.Error(),
134149
})
135150
}
136-
return ctx.JSON(setupIntent)
151+
marshalled, _ := json.Marshal(setupIntent)
152+
var payload interface{}
153+
json.Unmarshal(marshalled, &payload)
154+
return ctx.Status(200).JSON(payload)
137155
}
138156

139157
// RemoveCreditCard function
@@ -158,7 +176,10 @@ func (subscriptionEndpoint *SubscriptionEndpoint) RemoveCreditCard(ctx *fiber.Ct
158176
"message": err.Error(),
159177
})
160178
}
161-
return ctx.JSON(sCustomer)
179+
marshalled, _ := json.Marshal(sCustomer)
180+
var payload interface{}
181+
json.Unmarshal(marshalled, &payload)
182+
return ctx.Status(200).JSON(payload)
162183
}
163184

164185
// SetDefaultCreditCard function
@@ -183,7 +204,10 @@ func (subscriptionEndpoint *SubscriptionEndpoint) SetDefaultCreditCard(ctx *fibe
183204
"message": err.Error(),
184205
})
185206
}
186-
return ctx.JSON(sCustomer)
207+
marshalled, _ := json.Marshal(sCustomer)
208+
var payload interface{}
209+
json.Unmarshal(marshalled, &payload)
210+
return ctx.Status(200).JSON(payload)
187211
}
188212

189213
// Plans function
@@ -197,5 +221,5 @@ func (subscriptionEndpoint *SubscriptionEndpoint) Plans(ctx *fiber.Ctx) error {
197221
"message": err.Error(),
198222
})
199223
}
200-
return ctx.JSON(m)
224+
return ctx.Status(200).JSON(m)
201225
}

go.mod

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/devinterface/structomap v1.0.0
99
github.com/form3tech-oss/jwt-go v3.2.5+incompatible
1010
github.com/go-co-op/gocron v1.9.0
11-
github.com/gofiber/fiber/v2 v2.20.1
11+
github.com/gofiber/fiber/v2 v2.29.0
1212
github.com/gofiber/jwt/v3 v3.1.2
1313
github.com/golang-jwt/jwt/v4 v4.1.0
1414
github.com/google/uuid v1.3.0
@@ -22,35 +22,35 @@ require (
2222
github.com/thoas/go-funk v0.9.1
2323
github.com/xhit/go-simple-mail/v2 v2.10.0
2424
go.mongodb.org/mongo-driver v1.7.3
25-
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
26-
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect
25+
golang.org/x/crypto v0.0.0-20220214200702-86341886e292
26+
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect
2727
golang.org/x/text v0.3.7 // indirect
2828
)
2929

3030
require (
3131
github.com/BurntSushi/toml v0.4.1 // indirect
32-
github.com/andybalholm/brotli v1.0.3 // indirect
32+
github.com/andybalholm/brotli v1.0.4 // indirect
3333
github.com/davecgh/go-spew v1.1.1 // indirect
3434
github.com/fatih/structs v1.1.0 // indirect
3535
github.com/go-stack/stack v1.8.1 // indirect
3636
github.com/golang/snappy v0.0.4 // indirect
3737
github.com/huandu/xstrings v1.3.2 // indirect
3838
github.com/jinzhu/inflection v1.0.0 // indirect
39-
github.com/klauspost/compress v1.13.6 // indirect
39+
github.com/klauspost/compress v1.15.0 // indirect
4040
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
4141
github.com/osteele/tuesday v1.0.3 // indirect
4242
github.com/pkg/errors v0.9.1 // indirect
4343
github.com/pmezard/go-difflib v1.0.0 // indirect
4444
github.com/robfig/cron/v3 v3.0.1 // indirect
4545
github.com/stretchr/testify v1.7.0 // indirect
4646
github.com/valyala/bytebufferpool v1.0.0 // indirect
47-
github.com/valyala/fasthttp v1.30.0 // indirect
47+
github.com/valyala/fasthttp v1.34.0 // indirect
4848
github.com/valyala/tcplisten v1.0.0 // indirect
4949
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
5050
github.com/xdg-go/scram v1.0.2 // indirect
5151
github.com/xdg-go/stringprep v1.0.2 // indirect
5252
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
53-
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
53+
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
5454
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
5555
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
5656
gopkg.in/ini.v1 v1.66.2 // indirect

go.sum

+19
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ github.com/Kamva/mgm/v3 v3.0.1/go.mod h1:3F9EhA1QeVB6kk8oWZSHVAye/+af8EQBTuZ0gAR
66
github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
77
github.com/andybalholm/brotli v1.0.3 h1:fpcw+r1N1h0Poc1F/pHbW40cUm/lMEQslZtCkBQ0UnM=
88
github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
9+
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
10+
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
911
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ=
1012
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
1113
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -48,6 +50,8 @@ github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/V
4850
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
4951
github.com/gofiber/fiber/v2 v2.20.1 h1:p463gd/RI8YeYxP4WMGS+u1UtBS88yk8oLiPkEiDYx4=
5052
github.com/gofiber/fiber/v2 v2.20.1/go.mod h1:/LdZHMUXZvTTo7gU4+b1hclqCAdoQphNQ9bi9gutPyI=
53+
github.com/gofiber/fiber/v2 v2.29.0 h1:wopU1kXxdD9XxvQqYd1vSWMGu2PiZN0yy+DojygTRRA=
54+
github.com/gofiber/fiber/v2 v2.29.0/go.mod h1:1Ega6O199a3Y7yDGuM9FyXDPYQfv+7/y48wl6WCwUF4=
5155
github.com/gofiber/jwt/v3 v3.1.2 h1:Gsp1BgkUWo3ZbZZSSBJs+IVE1t89m1n/pOe0P9sIG/c=
5256
github.com/gofiber/jwt/v3 v3.1.2/go.mod h1:Z05kGvvdRqbWMvb3uYmAPwfFyCV8/n/QVorzq4XjwvU=
5357
github.com/golang-jwt/jwt/v4 v4.1.0 h1:XUgk2Ex5veyVFVeLm0xhusUTQybEbexJXrvPNOKkSY0=
@@ -84,6 +88,8 @@ github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0
8488
github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
8589
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
8690
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
91+
github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U=
92+
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
8793
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
8894
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
8995
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@@ -131,6 +137,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
131137
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
132138
github.com/stripe/stripe-go/v71 v71.48.0 h1:xSmbjHB1fdt6ieIf9yCGggafbzbXHPIhQj+R1gxTUHM=
133139
github.com/stripe/stripe-go/v71 v71.48.0/go.mod h1:BXYwMQe+xjYomcy5/qaTGyoyVMTP3wDCHa7DVFvg8+Y=
140+
github.com/stripe/stripe-go/v72 v72.91.0 h1:aZBz1IeXs2G3MAVmE4bYSBcVYcHrLWGyTz2CWIdbejs=
141+
github.com/stripe/stripe-go/v72 v72.91.0/go.mod h1:QwqJQtduHubZht9mek5sds9CtQcKFdsykV9ZepRWwo0=
134142
github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M=
135143
github.com/thoas/go-funk v0.9.1/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
136144
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
@@ -140,6 +148,8 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC
140148
github.com/valyala/fasthttp v1.29.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus=
141149
github.com/valyala/fasthttp v1.30.0 h1:nBNzWrgZUUHohyLPU/jTvXdhrcaf2m5k3bWk+3Q049g=
142150
github.com/valyala/fasthttp v1.30.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus=
151+
github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4=
152+
github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0=
143153
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
144154
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
145155
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
@@ -169,14 +179,19 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
169179
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
170180
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
171181
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
182+
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE=
183+
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
172184
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
173185
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
174186
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
175187
golang.org/x/net v0.0.0-20200927032502-5d4f70055728/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
176188
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
177189
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
190+
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
178191
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM=
179192
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
193+
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
194+
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
180195
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
181196
golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
182197
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -197,7 +212,11 @@ golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBc
197212
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
198213
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw=
199214
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
215+
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
216+
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 h1:nhht2DYV/Sn3qOayu8lM+cU1ii9sTLUeBQwQQfUHtrs=
217+
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
200218
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
219+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
201220
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
202221
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
203222
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

0 commit comments

Comments
 (0)