♻️ Return Entry instead map after creation
This commit is contained in:
parent
4ca6dc7f9f
commit
9240cd15cb
|
@ -266,17 +266,11 @@ func (h *Handler) handleCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set(common.HeaderLocation, out["self"].String())
|
w.Header().Set(common.HeaderLocation, out.URL.String())
|
||||||
|
|
||||||
if len(out)-1 <= 0 {
|
|
||||||
w.WriteHeader(http.StatusCreated)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
links := make([]string, 0)
|
links := make([]string, 0)
|
||||||
for rel, value := range out {
|
for i := range out.Syndications {
|
||||||
links = append(links, `<`+value.String()+`>; rel="`+rel+`"`)
|
links = append(links, `<`+out.Syndications[i].String()+`>; rel="syndication"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set(common.HeaderLink, strings.Join(links, ", "))
|
w.Header().Set(common.HeaderLink, strings.Join(links, ", "))
|
||||||
|
|
|
@ -11,7 +11,7 @@ type (
|
||||||
UseCase interface {
|
UseCase interface {
|
||||||
// Create creates a new entry. Returns map or rel links, like Permalink
|
// Create creates a new entry. Returns map or rel links, like Permalink
|
||||||
// or created post, shortcode and syndication.
|
// or created post, shortcode and syndication.
|
||||||
Create(ctx context.Context, e domain.Entry) (map[string]*url.URL, error)
|
Create(ctx context.Context, e domain.Entry) (*domain.Entry, error)
|
||||||
|
|
||||||
// Update updates exist entry properties on provided u.
|
// Update updates exist entry properties on provided u.
|
||||||
//
|
//
|
||||||
|
@ -61,8 +61,8 @@ func NewStubUseCase(err error, e *domain.Entry, ok bool) *stubUseCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ucase *stubUseCase) Create(ctx context.Context, e domain.Entry) (map[string]*url.URL, error) {
|
func (ucase *stubUseCase) Create(ctx context.Context, e domain.Entry) (*domain.Entry, error) {
|
||||||
return map[string]*url.URL{"self": ucase.entry.URL}, ucase.err
|
return ucase.entry, ucase.err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ucase *stubUseCase) Update(ctx context.Context, u *url.URL, e domain.Entry) (*domain.Entry, error) {
|
func (ucase *stubUseCase) Update(ctx context.Context, u *url.URL, e domain.Entry) (*domain.Entry, error) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user