mirror of
https://github.com/derfenix/webarchive.git
synced 2026-03-11 22:40:58 +03:00
Update deps, refactoring
This commit is contained in:
@@ -66,6 +66,29 @@ func PageToRestWithResults(page *entity.Page) openapi.PageWithResults {
|
||||
}
|
||||
}
|
||||
|
||||
func BasePageToRest(page *entity.PageBase) openapi.Page {
|
||||
return openapi.Page{
|
||||
ID: page.ID,
|
||||
URL: page.URL,
|
||||
Created: page.Created,
|
||||
Meta: openapi.PageMeta{
|
||||
Title: html.EscapeString(page.Meta.Title),
|
||||
Description: html.EscapeString(page.Meta.Description),
|
||||
Error: openapi.NewOptString(page.Meta.Error),
|
||||
},
|
||||
Formats: func() []openapi.Format {
|
||||
res := make([]openapi.Format, len(page.Formats))
|
||||
|
||||
for i, format := range page.Formats {
|
||||
res[i] = FormatToRest(format)
|
||||
}
|
||||
|
||||
return res
|
||||
}(),
|
||||
Status: StatusToRest(page.Status),
|
||||
}
|
||||
}
|
||||
|
||||
func PageToRest(page *entity.Page) openapi.Page {
|
||||
return openapi.Page{
|
||||
ID: page.ID,
|
||||
|
||||
@@ -85,7 +85,7 @@ func (s *Service) AddPage(ctx context.Context, req openapi.OptAddPageReq, params
|
||||
return nil, fmt.Errorf("save page: %w", err)
|
||||
}
|
||||
|
||||
res := PageToRest(page)
|
||||
res := BasePageToRest(&page.PageBase)
|
||||
|
||||
s.ch <- page
|
||||
|
||||
|
||||
Reference in New Issue
Block a user