Files
pages/internal/server/revision_restore.go
T
2026-05-19 21:30:42 +09:00

57 lines
690 B
Go

package server
import (
"net/http"
)
func (s *Server) handleRestoreRevisionAPI(
w http.ResponseWriter,
r *http.Request,
) {
revisionUUID :=
r.URL.Query().Get("revision")
row := s.store.DB.QueryRow(`
SELECT
object_uuid,
body
FROM revisions
WHERE uuid = ?
`, revisionUUID)
var objectUUID string
var body string
err := row.Scan(
&objectUUID,
&body,
)
if err != nil {
http.Error(
w,
err.Error(),
500,
)
return
}
_, err = s.store.SaveRevision(
objectUUID,
body,
"restore revision",
)
if err != nil {
http.Error(
w,
err.Error(),
500,
)
return
}
_, _ = w.Write([]byte("ok"))
}