16 lines
285 B
Go
16 lines
285 B
Go
|
package app
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"git.ctrlz.es/mgdelacroix/craban/model"
|
||
|
)
|
||
|
|
||
|
func (a *App) CreatePost(post *model.Post) (*model.Post, error) {
|
||
|
if err := post.IsValid(); err != nil {
|
||
|
return nil, fmt.Errorf("invalid post for creation: %w", err)
|
||
|
}
|
||
|
|
||
|
return a.Store.Post().Create(post)
|
||
|
}
|