Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions docs/filters/ProtobufFilter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## protobufFilter

### Description

Select exchanges having a protobuf request or response body. Filtering is made by inspecting value of `Content-Type` header on both request and response.

### Evaluation scope

Evaluation scope defines the timing where this filter will be applied.

{.alert .alert-info}
:::
**responseHeaderReceivedFromRemote** This scope occurs the moment fluxzy has done parsing the response header.
:::

### YAML configuration name

protobufFilter

### Settings

This filter has no specific characteristic

The following table describes the customizable properties available for this filter:

{.property-table .property-table-filter}
:::
| Property | Type | Description | DefaultValue |
| :------- | :------- | :------- | -------- |
| inverted | boolean | Negate the filter result | false |
:::

### Example of usage

The following examples apply a comment to the filtered exchange

Select exchanges with protobuf request or response body.

```yaml
rules:
- filter:
typeKind: ProtobufFilter
actions:
- typeKind: ApplyCommentAction
comment: filter was applied
```


Select exchanges without any protobuf body.

```yaml
rules:
- filter:
typeKind: ProtobufFilter
actions:
- typeKind: ApplyCommentAction
comment: filter was applied
```


### .NET reference

View definition of [ProtobufFilter](https://docs.fluxzy.io/api/Fluxzy.Rules.Filters.ProtobufFilter.html) for .NET integration.

### See also

This filter has no related filter

68 changes: 68 additions & 0 deletions docs/filters/ProtobufRequestFilter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## protobufRequestFilter

### Description

Select requests sending a protobuf body. Filtering is made by inspecting value of `Content-Type` header.

### Evaluation scope

Evaluation scope defines the timing where this filter will be applied.

{.alert .alert-info}
:::
**requestBodyReceivedFromClient** This scope occurs the moment fluxzy received fully the request body from the client. In a fullstreaming mode which is the default mode, this event occurs when the full body is already fully sent to the remote server.
:::

### YAML configuration name

protobufRequestFilter

### Settings

This filter has no specific characteristic

The following table describes the customizable properties available for this filter:

{.property-table .property-table-filter}
:::
| Property | Type | Description | DefaultValue |
| :------- | :------- | :------- | -------- |
| inverted | boolean | Negate the filter result | false |
:::

### Example of usage

The following examples apply a comment to the filtered exchange

Select only exchanges with protobuf request body.

```yaml
rules:
- filter:
typeKind: ProtobufRequestFilter
actions:
- typeKind: ApplyCommentAction
comment: filter was applied
```


Select exchanges without protobuf request body.

```yaml
rules:
- filter:
typeKind: ProtobufRequestFilter
actions:
- typeKind: ApplyCommentAction
comment: filter was applied
```


### .NET reference

View definition of [ProtobufRequestFilter](https://docs.fluxzy.io/api/Fluxzy.Rules.Filters.RequestFilters.ProtobufRequestFilter.html) for .NET integration.

### See also

This filter has no related filter

68 changes: 68 additions & 0 deletions docs/filters/ProtobufResponseFilter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## protobufResponseFilter

### Description

Select exchanges having protobuf response body. The content-type header is checked to determine if the content body is protobuf.

### Evaluation scope

Evaluation scope defines the timing where this filter will be applied.

{.alert .alert-info}
:::
**responseHeaderReceivedFromRemote** This scope occurs the moment fluxzy has done parsing the response header.
:::

### YAML configuration name

protobufResponseFilter

### Settings

This filter has no specific characteristic

The following table describes the customizable properties available for this filter:

{.property-table .property-table-filter}
:::
| Property | Type | Description | DefaultValue |
| :------- | :------- | :------- | -------- |
| inverted | boolean | Negate the filter result | false |
:::

### Example of usage

The following examples apply a comment to the filtered exchange

Select only exchanges with protobuf response body.

```yaml
rules:
- filter:
typeKind: ProtobufResponseFilter
actions:
- typeKind: ApplyCommentAction
comment: filter was applied
```


Select exchanges without protobuf response body.

```yaml
rules:
- filter:
typeKind: ProtobufResponseFilter
actions:
- typeKind: ApplyCommentAction
comment: filter was applied
```


### .NET reference

View definition of [ProtobufResponseFilter](https://docs.fluxzy.io/api/Fluxzy.Rules.Filters.ResponseFilters.ProtobufResponseFilter.html) for .NET integration.

### See also

This filter has no related filter

2 changes: 1 addition & 1 deletion docs/searchable-items.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Fluxzy.Core/Fluxzy.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<PackageReference Include="Fluxzy.BouncyCastle.Crypto.Async" Version="2.6.0" />
<PackageReference Include="MessagePack" Version="2.5.198" />
<PackageReference Include="SharpZipLib" Version="1.4.2" />
<PackageReference Include="Google.Protobuf" Version="3.29.3" />
<PackageReference Include="Google.Protobuf" Version="3.34.0" />
<PackageReference Include="YamlDotNet" Version="13.7.1" />
</ItemGroup>

Expand Down
61 changes: 61 additions & 0 deletions src/Fluxzy.Core/Rules/Filters/ProtobufFilter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2021 - Haga Rakotoharivelo - https://github.com/haga-rak

using System.Collections.Generic;
using Fluxzy.Rules.Extensions;
using Fluxzy.Rules.Filters.RequestFilters;
using Fluxzy.Rules.Filters.ResponseFilters;

namespace Fluxzy.Rules.Filters
{
/// <summary>
/// Select exchanges having a protobuf request or response body.
/// Filtering is made by inspecting value of `Content-Type` header on both request and response.
/// </summary>
[FilterMetaData(
LongDescription =
"Select exchanges having a protobuf request or response body. Filtering is made by inspecting value of `Content-Type` header on both request and response."
)]
public class ProtobufFilter : FilterCollection
{
public ProtobufFilter()
: base(new ProtobufRequestFilter(), new ProtobufResponseFilter())
{
Operation = SelectorCollectionOperation.Or;
}

public override string GenericName => "Protobuf exchange";

public override string AutoGeneratedName { get; } = "Protobuf";

public override string ShortName => "protobuf";

public override bool PreMadeFilter => true;

public override string Description => "Protobuf exchanges (request or response)";

public override IEnumerable<FilterExample> GetExamples()
{
yield return new FilterExample(
"Select exchanges with protobuf request or response body",
new ProtobufFilter());

yield return new FilterExample(
"Select exchanges without any protobuf body",
new ProtobufFilter { Inverted = true });
}
}

public static class ProtobufFilterExtensions
{
/// <summary>
/// When exchange has a protobuf request or response body.
/// Filtering is made by inspecting value of `Content-Type` header on both request and response.
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static IConfigureActionBuilder WhenIsProtobuf(this IConfigureFilterBuilder builder)
{
return builder.When(new ProtobufFilter());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2021 - Haga Rakotoharivelo - https://github.com/haga-rak

using System.Collections.Generic;
using Fluxzy.Core;
using Fluxzy.Rules.Extensions;

namespace Fluxzy.Rules.Filters.RequestFilters
{
/// <summary>
/// Select requests sending a protobuf body. Filtering is made by inspecting value of `Content-Type` header
/// for `application/x-protobuf` or `application/protobuf`.
/// </summary>
[FilterMetaData(
LongDescription =
"Select requests sending a protobuf body. Filtering is made by inspecting value of `Content-Type` header."
)]
public class ProtobufRequestFilter : RequestHeaderFilter
{
public ProtobufRequestFilter()
: base("protobuf", StringSelectorOperation.Contains, "content-type")
{
}

public override FilterScope FilterScope => FilterScope.RequestBodyReceivedFromClient;

public override string GenericName => "Has a request body protobuf";

public override string AutoGeneratedName { get; } = "Protobuf request body";

public override string ShortName => "snt. protobuf";

public override bool PreMadeFilter => true;

public override IEnumerable<FilterExample> GetExamples()
{
yield return new FilterExample(
"Select only exchanges with protobuf request body",
new ProtobufRequestFilter());

yield return new FilterExample(
"Select exchanges without protobuf request body",
new ProtobufRequestFilter { Inverted = true });
}
}

public static class ProtobufRequestFilterExtensions
{
/// <summary>
/// When request has a protobuf body. Filtering is made by inspecting value of `Content-Type` header.
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static IConfigureActionBuilder WhenRequestHasProtobufBody(this IConfigureFilterBuilder builder)
{
return builder.When(new ProtobufRequestFilter());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2021 - Haga Rakotoharivelo - https://github.com/haga-rak

using System.Collections.Generic;
using Fluxzy.Rules.Extensions;

namespace Fluxzy.Rules.Filters.ResponseFilters
{
/// <summary>
/// Select exchanges having a protobuf response body. Filtering is made by inspecting value of `Content-Type` header
/// for `application/x-protobuf` or `application/protobuf`.
/// </summary>
[FilterMetaData(
LongDescription =
"Select exchanges having protobuf response body. The content-type header is checked to determine if the content body is protobuf."
)]
public class ProtobufResponseFilter : ResponseHeaderFilter
{
public ProtobufResponseFilter()
: base("protobuf", StringSelectorOperation.Contains, "Content-Type")
{
}

public override string AutoGeneratedName { get; } = "Protobuf response only";

public override string GenericName => "Protobuf response only";

public override string ShortName => "protobuf";

public override bool PreMadeFilter => true;

public override IEnumerable<FilterExample> GetExamples()
{
yield return new FilterExample(
"Select only exchanges with protobuf response body",
new ProtobufResponseFilter());

yield return new FilterExample(
"Select exchanges without protobuf response body",
new ProtobufResponseFilter { Inverted = true });
}
}

public static class ProtobufResponseFilterExtensions
{
/// <summary>
/// When response has a protobuf body. Filtering is made by inspecting value of `Content-Type` header.
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static IConfigureActionBuilder WhenResponseHasProtobufBody(this IConfigureFilterBuilder builder)
{
return builder.When(new ProtobufResponseFilter());
}
}
}
Loading
Loading