Skip to content
Myr

feat(context): implemented Delete method

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Spyder01 · committed by GitHub · parent c221133 · Browse files · 2 files+23 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: suhan <s.bangera@castsoftware.com>

Diff stats

2 files+23 added−0 removed

  • other:+23 added−0 removed

2 files+23 added−0 removed

modified:context_test.go+13 added
402 unmodified lines
403 c.Set("bool", true)404 assert.True(t, c.GetBool("bool"))405}406407func TestSetGetDelete(t *testing.T) {408 c, _ := CreateTestContext(httptest.NewRecorder())409 key := "example-key"410 value := "example-value"411 c.Set(key, value)412 val, exists := c.Get(key)413 assert.True(t, exists)414 assert.Equal(t, val, value)415 c.Delete(key)416 _, exists = c.Get(key)417 assert.False(t, exists)418}419420func TestContextGetInt(t *testing.T) {421 c, _ := CreateTestContext(httptest.NewRecorder())422 c.Set("int", 1)423 assert.Equal(t, 1, c.GetInt("int"))
3230 unmodified lines
modified:context.go+10 added
463 unmodified lines
464func (c *Context) GetStringMapStringSlice(key any) (smss map[string][]string) {465 return getTyped[map[string][]string](c, key)466}467468// Delete deletes the key from the Context's Key map, if it exists.469// This operation is safe to be used by concurrent go-routines470func (c *Context) Delete(key any) {471 c.mu.Lock()472 defer c.mu.Unlock()473 if c.Keys != nil {474 delete(c.Keys, key)475 }476}477478/************************************/479/************ INPUT DATA ************/480/************************************/481
930 unmodified lines