42 lines
408 B
Go
42 lines
408 B
Go
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func (s *Server) handleNewPage(
|
|
w http.ResponseWriter,
|
|
r *http.Request,
|
|
) {
|
|
|
|
draftPath := fmt.Sprintf(
|
|
"/draft/%d",
|
|
time.Now().UnixNano(),
|
|
)
|
|
|
|
_, err :=
|
|
s.store.CreateObject(
|
|
draftPath,
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
http.Error(
|
|
w,
|
|
err.Error(),
|
|
500,
|
|
)
|
|
|
|
return
|
|
}
|
|
|
|
http.Redirect(
|
|
w,
|
|
r,
|
|
"/e"+draftPath,
|
|
http.StatusFound,
|
|
)
|
|
}
|