setup(save_note): setup save handler
This commit is contained in:
parent
f9b9a06b70
commit
716a541005
2 changed files with 33 additions and 0 deletions
33
core/handlers/save_note.go
Normal file
33
core/handlers/save_note.go
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/KristianJBorgwarth/dendrite.daemon/persistence/repositories"
|
||||||
|
)
|
||||||
|
|
||||||
|
type saveNoteCommand struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
Directory string `json:"directory"`
|
||||||
|
Tags []string `json:"tags"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SaveNoteHandler struct {
|
||||||
|
uow *repositories.UnitOfWork
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSaveNoteHandler() *SaveNoteHandler {
|
||||||
|
return &SaveNoteHandler{repositories.NewUnitOfWork()}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *SaveNoteHandler) Handle(ctx context.Context, raw json.RawMessage) (any, error) {
|
||||||
|
var cmd saveNoteCommand
|
||||||
|
|
||||||
|
if err := json.Unmarshal(raw, &cmd); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
BIN
dendrite
BIN
dendrite
Binary file not shown.
Loading…
Add table
Reference in a new issue