mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-13 17:42:53 +08:00
Add CORS to create session and make it return text plain session ID
This commit is contained in:
parent
d1d69e5ff0
commit
c81a712a28
2
api.go
2
api.go
@ -79,7 +79,7 @@ func main() {
|
||||
}
|
||||
}).Methods("GET")
|
||||
|
||||
r.HandleFunc("/", handlers.NewSession).Methods("POST")
|
||||
r.Handle("/", c.Handler(http.HandlerFunc(handlers.NewSession))).Methods("POST")
|
||||
|
||||
n := negroni.Classic()
|
||||
n.UseHandler(r)
|
||||
|
@ -21,6 +21,11 @@ func NewSession(rw http.ResponseWriter, req *http.Request) {
|
||||
log.Println(err)
|
||||
//TODO: Return some error code
|
||||
} else {
|
||||
// If request is not a form, return sessionId in the body
|
||||
if req.Header.Get("Content-Type") != "application/x-www-form-urlencoded" {
|
||||
rw.Write([]byte(s.Id))
|
||||
return
|
||||
}
|
||||
http.Redirect(rw, req, fmt.Sprintf("/p/%s", s.Id), http.StatusFound)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user