Add close session endpoint

This commit is contained in:
Marcos Lilljedahl
2017-09-26 09:38:08 -03:00
parent 98735a5a93
commit 1a7a776a27
2 changed files with 27 additions and 0 deletions

26
handlers/close_session.go Normal file
View File

@@ -0,0 +1,26 @@
package handlers
import (
"log"
"net/http"
"github.com/gorilla/mux"
)
func CloseSession(rw http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
sessionId := vars["sessionId"]
session := core.SessionGet(sessionId)
if session == nil {
rw.WriteHeader(http.StatusNotFound)
return
}
if err := core.SessionClose(session); err != nil {
log.Println(err)
rw.WriteHeader(http.StatusInternalServerError)
return
}
}