1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-07-13 17:42:53 +08:00
docker-labs/handlers/new_session.go
Marcos Lilljedahl c1cfc7958a Revert "Add CORS to create session and make it return text plain session ID"
This reverts commit c81a712a28eba960a4bcdc078cb51a1a4f832dbb.
2017-01-13 19:27:07 -03:00

27 lines
506 B
Go

package handlers
import (
"fmt"
"log"
"net/http"
"github.com/franela/play-with-docker/services"
)
func NewSession(rw http.ResponseWriter, req *http.Request) {
if !services.IsHuman(req) {
// User it not a human
rw.WriteHeader(http.StatusConflict)
rw.Write([]byte("Only humans are allowed!"))
return
}
s, err := services.NewSession()
if err != nil {
log.Println(err)
//TODO: Return some error code
} else {
http.Redirect(rw, req, fmt.Sprintf("/p/%s", s.Id), http.StatusFound)
}
}