Conversation
qraimbault
left a comment
There was a problem hiding this comment.
Still some work to do but nice job 👍
| CMD go run main.go | ||
| RUN go mod download | ||
|
|
||
| EXPOSE 8080 No newline at end of file |
| "time" | ||
| ) | ||
|
|
||
| type UserSession struct { |
There was a problem hiding this comment.
Your user session should not be stored in DB. You can either store it in an in-memory cache (redis/memcached/consul for example) or use a manager with a mutex (see https://astaxie.gitbooks.io/build-web-application-with-golang/content/en/06.2.html for more details and example)
| "net/http" | ||
| ) | ||
|
|
||
| func CheckAuthorization(c *gin.Context) { |
There was a problem hiding this comment.
Missing comment for this exported function
| if err != nil { | ||
| if err == http.ErrNoCookie { | ||
| c.Redirect(http.StatusPermanentRedirect, "/login") | ||
| c.Abort() |
There was a problem hiding this comment.
IIRC you just need to return but there is no need to abort
| # Run command to nstall the dependencies | ||
| RUN go install | ||
|
|
||
| CMD go run main.go |
There was a problem hiding this comment.
If you remove your go run, you then need to compile and start the binary or nothing will happen
| "github.com/jasongauvin/wikiPattern/services" | ||
| ) | ||
|
|
||
| func ValidateArticle(article *services.ArticleForm) error { |
There was a problem hiding this comment.
Missing comment for this exported function
| "github.com/jasongauvin/wikiPattern/services" | ||
| ) | ||
|
|
||
| func ValidateComment(comment *services.CommentForm) error { |
There was a problem hiding this comment.
Missing comment for this exported function
| if article.Title == "" { | ||
| return errors.New("Required title") | ||
| } | ||
| if article.Content == "" { | ||
| return errors.New("Required content") | ||
| } |
There was a problem hiding this comment.
What if we are missing both ? Maybe return a slice of errors
| "strings" | ||
| ) | ||
|
|
||
| func ValidateUser(user *models.User, action string) error { |
There was a problem hiding this comment.
Missing comment for this exported function
There was a problem hiding this comment.
Also, comment about slice of errors applies here too
|
|
||
| func ValidateUser(user *models.User, action string) error { | ||
| switch strings.ToLower(action) { | ||
| case "update": |
There was a problem hiding this comment.
Don't use a switch. ValidateUser should validate the entire user, and does not depend of it being updated or created or whatever. Also you user validator is not meant to also validate your login form, these are 2 completely different things
No description provided.