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

View file

@ -18,6 +18,15 @@ func (s *Server) handleApiService(c iris.Context) {
return 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 // Return the service as JSON
c.JSON(service) c.JSON(service)
} }