♻️ 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
|
||||
}
|
||||
|
||||
w.Header().Set(common.HeaderLocation, out["self"].String())
|
||||
|
||||
if len(out)-1 <= 0 {
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
|
||||
return
|
||||
}
|
||||
w.Header().Set(common.HeaderLocation, out.URL.String())
|
||||
|
||||
links := make([]string, 0)
|
||||
for rel, value := range out {
|
||||
links = append(links, `<`+value.String()+`>; rel="`+rel+`"`)
|
||||
for i := range out.Syndications {
|
||||
links = append(links, `<`+out.Syndications[i].String()+`>; rel="syndication"`)
|
||||
}
|
||||
|
||||
w.Header().Set(common.HeaderLink, strings.Join(links, ", "))
|
||||
|
|
|
@ -11,7 +11,7 @@ type (
|
|||
UseCase interface {
|
||||
// Create creates a new entry. Returns map or rel links, like Permalink
|
||||
// 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.
|
||||
//
|
||||
|
@ -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) {
|
||||
return map[string]*url.URL{"self": ucase.entry.URL}, ucase.err
|
||||
func (ucase *stubUseCase) Create(ctx context.Context, e domain.Entry) (*domain.Entry, error) {
|
||||
return ucase.entry, ucase.err
|
||||
}
|
||||
|
||||
func (ucase *stubUseCase) Update(ctx context.Context, u *url.URL, e domain.Entry) (*domain.Entry, error) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user