+++ title = "HitCounter API の定義" weight = 100 +++ ## HitCounter コンストラクトのためのファイルを作成 `src/CdkWorkshop` の配下に `HitCounter.cs` というファイルを以下の内容で作成します。 ```csharp using Amazon.CDK; using Amazon.CDK.AWS.Lambda; using Constructs; namespace CdkWorkshop { public class HitCounterProps { // The function for which we want to count url hits public IFunction Downstream { get; set; } } public class HitCounter : Construct { public HitCounter(Construct scope, string id, HitCounterProps props) : base(scope, id) { // TODO } } } ``` ファイルを保存すると、エラーが発生しますが心配いりません。 この後すぐに `props` プロパティを追加します。 ## ここで何が起こったのでしょうか? * `HitCounter` という名前のコンストラクトクラスを新しく定義しています。 * これまでどおり、`scope`、`id`、`props` のコンストラクター引数を設定し、基底クラスである cdk.Construct に伝搬させます。 * `props` は、`IFunction` 型の `Downstream` というプロパティを含む、`HitCounterProps` 型の引数です。前の章で作成したLambda関数をここに接続して、HitCountが機能するようにします。