A community based topic aggregation platform built on atproto
at main 1.2 kB view raw
1package comments 2 3import ( 4 "Coves/internal/core/comments" 5 "net/http" 6) 7 8// ServiceAdapter adapts the core comments.Service to the handler's Service interface 9// This bridges the gap between HTTP-layer concerns (http.Request) and domain-layer concerns (context.Context) 10type ServiceAdapter struct { 11 coreService comments.Service 12} 13 14// NewServiceAdapter creates a new service adapter wrapping the core comment service 15func NewServiceAdapter(coreService comments.Service) Service { 16 return &ServiceAdapter{ 17 coreService: coreService, 18 } 19} 20 21// GetComments adapts the handler request to the core service request 22// Converts handler-specific GetCommentsRequest to core GetCommentsRequest 23func (a *ServiceAdapter) GetComments(r *http.Request, req *GetCommentsRequest) (*comments.GetCommentsResponse, error) { 24 // Convert handler request to core service request 25 coreReq := &comments.GetCommentsRequest{ 26 PostURI: req.PostURI, 27 Sort: req.Sort, 28 Timeframe: req.Timeframe, 29 Depth: req.Depth, 30 Limit: req.Limit, 31 Cursor: req.Cursor, 32 ViewerDID: req.ViewerDID, 33 } 34 35 // Call core service with request context 36 return a.coreService.GetComments(r.Context(), coreReq) 37}