craban/server/app/post.go

16 lines
285 B
Go
Raw Permalink Normal View History

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