@@ -766,10 +766,27 @@ func (c Cookie) DelCookies(key ...string) {
766
766
}
767
767
768
768
// VisitAll iterates through all cookies, calling f for each.
769
+ // All returns an iterator over cookie key-value pairs.
770
+ //
771
+ // The returned key and value should not be retained after the iteration loop.
772
+ func (c Cookie ) All () iter.Seq2 [string , string ] {
773
+ return func (yield func (string , string ) bool ) {
774
+ for k , v := range c {
775
+ if ! yield (k , v ) {
776
+ break
777
+ }
778
+ }
779
+ }
780
+ }
781
+
782
+ // VisitAll iterates through all cookies, calling f for each.
783
+ //
784
+ // Deprecated: Use All instead.
769
785
func (c Cookie ) VisitAll (f func (key , val string )) {
770
- for k , v := range c {
786
+ c . All ()( func ( k , v string ) bool {
771
787
f (k , v )
772
- }
788
+ return true
789
+ })
773
790
}
774
791
775
792
// Reset clears the Cookie map.
@@ -816,10 +833,27 @@ func (p PathParam) DelParams(key ...string) {
816
833
}
817
834
818
835
// VisitAll iterates through all path parameters, calling f for each.
836
+ // All returns an iterator over path parameter key-value pairs.
837
+ //
838
+ // The returned key and value should not be retained after the iteration loop.
839
+ func (p PathParam ) All () iter.Seq2 [string , string ] {
840
+ return func (yield func (string , string ) bool ) {
841
+ for k , v := range p {
842
+ if ! yield (k , v ) {
843
+ break
844
+ }
845
+ }
846
+ }
847
+ }
848
+
849
+ // VisitAll iterates through all path parameters, calling f for each.
850
+ //
851
+ // Deprecated: Use All instead.
819
852
func (p PathParam ) VisitAll (f func (key , val string )) {
820
- for k , v := range p {
853
+ p . All ()( func ( k , v string ) bool {
821
854
f (k , v )
822
- }
855
+ return true
856
+ })
823
857
}
824
858
825
859
// Reset clears the PathParam map.
0 commit comments