Skip to content

Commit

Permalink
Updated logout controller.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno.chavez committed Apr 2, 2019
1 parent e35a222 commit 83355bc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Description

`go-web-template` main purpose is to be a starting point
for a web back-end developed in Go, usually just as a
REST API for any kind of front-end project.
for web development in Go,
usually just as a API for a front-end application.

# How to use

Expand All @@ -19,9 +19,9 @@ $ go install

3. Have Redis installed and a server running.

4. Have PostgresSQL installed.
4. Have PostgresSQL installed and a database created.

5. Run migrations.
5. Run migrations or alternately create the table manually.

6. Create an `.env` file at root level, example:
```
Expand All @@ -39,7 +39,7 @@ FRONT-END-ADDRESS=http://example.com
+ Ready to use custom authentication routes, for registering,
login in and login out users.

+ Ready to use session management with
+ Ready to use cookie based session management with
[gorilla/sessions](https://github.com/gorilla/sessions) and
Redis as a session store with
[redistore](https://github.com/boj/redistore).
Expand Down Expand Up @@ -74,7 +74,8 @@ with the help of [godotenv](https://github.com/joho/godotenv).
and the db connection pool thanks to dependency injection.
Simply reference `c.Db` or `c.SessionStore` once
your handlers are methods of the `Controller` struct.
See how the methods `PostRegister` and `PostLogin` are implemented
See how the methods `PostRegister`, `PostLogin`
and `DeleteLogout` are implemented
for examples of how you can access the db pool
or the session store from any controller.

Expand Down
2 changes: 1 addition & 1 deletion controllers/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
)

func (c *Controller) PostLogout(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
func (c *Controller) DeleteLogout(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
session, err := c.SessionStore.Get(r, "user")
if err != nil {
log.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func main() {
// lists routes with the controller methods
router.POST("/register", controller.PostRegister)
router.POST("/login", controller.PostLogin)
router.POST("/logout", controller.PostLogout)
router.DELETE("/logout", controller.DeleteLogout)

// binds cors options to the router
c := cors.New(cors.Options{
Expand Down

0 comments on commit 83355bc

Please sign in to comment.