@@ -12,10 +12,12 @@ import "github.com/greenbone/opensight-golang-libraries/pkg/httpassert"
1212
1313- [ Constants] ( < #constants > )
1414- [ type Extractor] ( < #Extractor > )
15+ - [ func ExtractRegexTo\( value string, ptr any\) Extractor] ( < #ExtractRegexTo > )
1516 - [ func ExtractTo\( ptr any\) Extractor] ( < #ExtractTo > )
1617- [ type Matcher] ( < #Matcher > )
1718 - [ func Contains\( v string\) Matcher] ( < #Contains > )
1819 - [ func HasSize\( e int\) Matcher] ( < #HasSize > )
20+ - [ func Regex\( expr string\) Matcher] ( < #Regex > )
1921- [ type Request] ( < #Request > )
2022 - [ func New\( t \* testing.T, router http.Handler\) Request] ( < #New > )
2123- [ type Response] ( < #Response > )
@@ -30,16 +32,25 @@ const IgnoreJsonValue = "<IGNORE>"
3032```
3133
3234<a name =" Extractor " ></a >
33- ## type [ Extractor] ( < https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/extracter.go#L15 > )
35+ ## type [ Extractor] ( < https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/extracter.go#L16 > )
3436
3537
3638
3739``` go
3840type Extractor func (t *testing.T , actual any) any
3941```
4042
43+ <a name =" ExtractRegexTo " ></a >
44+ ### func [ ExtractRegexTo] ( < https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/extracter.go#L29 > )
45+
46+ ``` go
47+ func ExtractRegexTo (value string , ptr any ) Extractor
48+ ```
49+
50+
51+
4152<a name="ExtractTo"></a>
42- ### func [ ExtractTo] ( < https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/extracter.go#L22 > )
53+ ### func [ExtractTo](<https:// github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/extracter.go#L23 >)
4354
4455```go
4556func ExtractTo(ptr any) Extractor
@@ -53,7 +64,7 @@ request.Expect().JsonPath("$.data.id", httpassert.ExtractTo(&id))
5364```
5465
5566<a name="Matcher"></a>
56- ## type [Matcher](<https:// github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/matcher.go#L14 >)
67+ ## type [Matcher](<https:// github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/matcher.go#L15 >)
5768
5869
5970
@@ -62,7 +73,7 @@ type Matcher func(t *testing.T, actual any) bool
6273```
6374
6475<a name="Contains"></a>
65- ### func [Contains](<https:// github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/matcher.go#L42 >)
76+ ### func [Contains](<https:// github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/matcher.go#L43 >)
6677
6778```go
6879func Contains(v string) Matcher
@@ -71,14 +82,23 @@ func Contains(v string) Matcher
7182Contains checks if a string contains the value Example: ExpectJsonPath\("$.data.name", httpassert.Contains\("foo"\)\)
7283
7384<a name="HasSize"></a>
74- ### func [HasSize](<https:// github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/matcher.go#L18 >)
85+ ### func [HasSize](<https:// github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/matcher.go#L19 >)
7586
7687```go
7788func HasSize(e int) Matcher
7889```
7990
8091HasSize checks the length of arrays, maps, or strings. Example: ExpectJsonPath\("$.data", httpassert.HasSize\(11\)\)
8192
93+ <a name="Regex"></a>
94+ ### func [Regex](<https:// github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/matcher.go#L52>)
95+
96+ ```go
97+ func Regex(expr string) Matcher
98+ ```
99+
100+ Regex checks if a string matches the given regular expression Example: ExpectJsonPath\("$.data.name", httpassert.Regex\("^foo.\*bar$"\)\)
101+
82102<a name="Request"></a>
83103## type [Request](<https:// github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/request.go#L23-L55>)
84104
@@ -130,7 +150,7 @@ func New(t *testing.T, router http.Handler) Request
130150New returns a new Request instance for the given router.
131151
132152<a name="Response"></a>
133- ## type [Response](<https:// github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/response.go#L24-L44 >)
153+ ## type [Response](<https:// github.com/greenbone/opensight-golang-libraries/blob/main/pkg/httpassert/response.go#L24-L46 >)
134154
135155nolint:interfacebloat Response interface provides fluent response assertions.
136156
@@ -150,6 +170,8 @@ type Response interface {
150170 JsonTemplateFile (path string , values map [string ]any) Response
151171 JsonFile (path string ) Response
152172
173+ Header (name string , value any) Response
174+
153175 Body (body string ) Response
154176 GetJsonBodyObject (target any) Response
155177 GetBody () string
0 commit comments