Created
November 16, 2020 07:41
-
-
Save asim/a1870dccc4ad1eb137a602ae9e884af6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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