2023-06-07 20:51:54 +03:00
|
|
|
package web
|
|
|
|
|
|
|
|
import (
|
2023-06-17 18:00:44 +03:00
|
|
|
"errors"
|
2023-06-07 20:51:54 +03:00
|
|
|
"github.com/lus/pasty/internal/pastes"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (server *Server) v2EndpointGetPaste(writer http.ResponseWriter, request *http.Request) {
|
|
|
|
paste, ok := request.Context().Value("paste").(*pastes.Paste)
|
|
|
|
if !ok {
|
2023-06-17 18:00:44 +03:00
|
|
|
writeErr(request, writer, errors.New("missing paste object"))
|
2023-06-07 20:51:54 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
cpy := *paste
|
|
|
|
cpy.ModificationToken = ""
|
2023-06-17 18:00:44 +03:00
|
|
|
writeJSONOrErr(request, writer, http.StatusOK, cpy)
|
2023-06-07 20:51:54 +03:00
|
|
|
}
|