Skip to content

Instantly share code, notes, and snippets.

@asim
Created November 16, 2020 07:41
Show Gist options
  • Save asim/a1870dccc4ad1eb137a602ae9e884af6 to your computer and use it in GitHub Desktop.
Save asim/a1870dccc4ad1eb137a602ae9e884af6 to your computer and use it in GitHub Desktop.
func (p *Posts) Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.SaveResponse) error {
logger.Info("Received Posts.Save request")
post := &proto.Post{
Id: req.Id,
Title: req.Title,
Content: req.Content,
Slug: req.Slug,
Created: time.Now().Unix(),
}
if req.Slug == "" {
post.Slug = slug.Make(req.Title)
}
return p.db.Save(post)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment