optimize api response

This commit is contained in:
pluja 2024-05-07 23:12:15 +02:00
parent 3e5090ccb6
commit 4da4416cd9
No known key found for this signature in database
2 changed files with 14 additions and 5 deletions

View File

@ -4,11 +4,11 @@ type Service struct {
Category string `json:"category"`
CollectionID string `json:"collectionId"`
CollectionName string `json:"collectionName"`
Comments []string `json:"comments"`
Comments []string `json:"comments,omitempty"`
Created string `json:"created"`
Description string `json:"description"`
Expand map[string][]Attribute `json:"expand"`
Attributes []string `json:"attributes"`
Expand map[string][]Attribute `json:"expand,omitempty"`
Attributes []string `json:"attributes,omitempty"`
ID string `json:"id"`
KycLevel int `json:"kyc_level"`
Listed bool `json:"listed"`
@ -18,7 +18,7 @@ type Service struct {
Pending bool `json:"pending"`
Score int `json:"score"`
Tags []string `json:"tags"`
TosReviews []TosReview `json:"tos_reviews"`
TosReviews []TosReview `json:"tos_reviews,omitempty"`
LastTosReview string `json:"last_tos_review"`
TosUrls []string `json:"tos_urls"`
Type string `json:"type"`
@ -31,7 +31,7 @@ type Service struct {
Fiat bool `json:"fiat"`
Cash bool `json:"cash"`
Lightning bool `json:"lightning"`
Notes []string `json:"notes"`
Notes []string `json:"notes,omitempty"`
}
type TosReview struct {

View File

@ -18,6 +18,15 @@ func (s *Server) handleApiService(c iris.Context) {
return
}
// Remove 'tosReviews' service field to make a shorter answer
service.TosReviews = nil
service.Notes = nil
service.Comments = nil
service.Expand = nil
service.Attributes = nil
// Ensure to remove any other additional unnecessary fields to ensure code efficiency and better clarity.
// Return the service as JSON
c.JSON(service)
}