3 files changed,
6 insertions(+),
26 deletions(-)
Author:
Smirnov Olexandr
ss2316544@gmail.com
Committed by:
GitHub
noreply@github.com
Committed at:
2025-06-30 18:29:48 +0300
Parent:
450a6a9
M
e2e/apiv1_notes_test.go
@@ -139,10 +139,6 @@ e.Equal(dbNote.Content, "")
e.Equal(dbNote.ReadAt.IsZero(), false) } -type apiv1NoteGetRequest struct { - Password string `json:"password"` -} - func (e *AppTestSuite) TestNoteV1_GetWithPassword() { content := e.uuid() passwd := e.uuid()@@ -161,10 +157,8 @@ e.readBodyAndUnjsonify(httpResp.Body, &bodyCreated)
httpResp = e.httpRequest( http.MethodGet, - "/api/v1/note/"+bodyCreated.Slug, - e.jsonify(apiv1NoteGetRequest{ - Password: passwd, - }), + "/api/v1/note/"+bodyCreated.Slug+"?password="+passwd, + nil, ) e.Equal(httpResp.Code, http.StatusOK)@@ -215,10 +209,8 @@ e.readBodyAndUnjsonify(httpResp.Body, &bodyCreated)
httpResp = e.httpRequest( http.MethodGet, - "/api/v1/note/"+bodyCreated.Slug, - e.jsonify(apiv1NoteGetRequest{ - Password: e.uuid(), - }), + "/api/v1/note/"+bodyCreated.Slug+"?password="+e.uuid(), + nil, ) e.Equal(httpResp.Code, http.StatusNotFound) }
M
internal/service/notesrv/input.go
@@ -8,7 +8,7 @@ // Slug is a note's slug :) *Required*
Slug dtos.NoteSlug // Password is a note's password. - // Optional, needed only if note has one. + // Leave it `""` if note has no password. Password string }
M
internal/transport/http/apiv1/note.go
@@ -1,8 +1,6 @@
package apiv1 import ( - "errors" - "io" "net/http" "time"@@ -49,10 +47,6 @@
c.JSON(http.StatusCreated, createNoteResponse{slug}) } -type getNoteBySlugRequest struct { - Password string `json:"password"` -} - type getNoteBySlugResponse struct { Content string `json:"content"` ReadAt time.Time `json:"read_at,omitzero"`@@ -62,17 +56,11 @@ ExpiresAt time.Time `json:"expires_at,omitzero"`
} func (a *APIV1) getNoteBySlugHandler(c *gin.Context) { - var req getNoteBySlugRequest - if err := c.ShouldBindJSON(&req); err != nil && !errors.Is(err, io.EOF) { - newError(c, http.StatusBadRequest, "invalid request") - return - } - note, err := a.notesrv.GetBySlugAndRemoveIfNeeded( c.Request.Context(), notesrv.GetNoteBySlugInput{ Slug: c.Param("slug"), - Password: req.Password, + Password: c.Query("password"), }, ) if err != nil {