Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
romsar committed Oct 19, 2024
1 parent ff08ab9 commit 2690e1c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ Simple inmemory implementation of flash provider:
```go
type InmemFlashProvider struct {
errors map[string]inertia.ValidationErrors
clearHistory map[string]bool
}

func NewInmemFlashProvider() *InmemFlashProvider {
Expand All @@ -317,9 +318,22 @@ func (p *InmemFlashProvider) FlashErrors(ctx context.Context, errors ValidationE
func (p *InmemFlashProvider) GetErrors(ctx context.Context) (ValidationErrors, error) {
sessionID := getSessionIDFromContext(ctx)
errors := p.errors[sessionID]
p.errors[sessionID] = nil
delete(p.errors, sessionID)
return errors, nil
}

func (p *InmemFlashProvider) FlashClearHistory(ctx context.Context) error {
sessionID := getSessionIDFromContext(ctx)
p.clearHistory[sessionID] = true
return nil
}

func (p *InmemFlashProvider) ShouldClearHistory(ctx context.Context) (bool, error) {
sessionID := getSessionIDFromContext(ctx)
clearHistory := p.clearHistory[sessionID]
delete(p.clearHistory, sessionID)
return clearHistory
}
```

#### History encryption ([learn more](https://v2.inertiajs.com/history-encryption))
Expand Down

0 comments on commit 2690e1c

Please sign in to comment.