craban/server/app/post.go
2021-09-25 17:23:56 +02:00

15 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)
}