# AllowedMethods

The HTTP methods that the Behavior will accept requests on.

Obtainable from: AllowedMethods.ALLOW_ALL, AllowedMethods.ALLOW_GET_HEAD, AllowedMethods.ALLOW_GET_HEAD_OPTIONS

- Source: [`aws-cloudfront/lib/distribution.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts#L1018)

## Example

TypeScript:

```ts
// Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
declare const myBucket: s3.Bucket;
const myWebDistribution = new cloudfront.Distribution(this, 'myDist', {
  defaultBehavior: {
    origin: new origins.S3Origin(myBucket),
    allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
    viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
  },
});
```

Python:

```python
# Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
# my_bucket: s3.Bucket

my_web_distribution = cloudfront.Distribution(self, "myDist",
    default_behavior=cloudfront.BehaviorOptions(
        origin=origins.S3Origin(my_bucket),
        allowed_methods=cloudfront.AllowedMethods.ALLOW_ALL,
        viewer_protocol_policy=cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS
    )
)
```

Java:

```java
// Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
Bucket myBucket;

Distribution myWebDistribution = Distribution.Builder.create(this, "myDist")
        .defaultBehavior(BehaviorOptions.builder()
                .origin(new S3Origin(myBucket))
                .allowedMethods(AllowedMethods.ALLOW_ALL)
                .viewerProtocolPolicy(ViewerProtocolPolicy.REDIRECT_TO_HTTPS)
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
Bucket myBucket;

var myWebDistribution = new Distribution(this, "myDist", new DistributionProps {
    DefaultBehavior = new BehaviorOptions {
        Origin = new S3Origin(myBucket),
        AllowedMethods = AllowedMethods.ALLOW_ALL,
        ViewerProtocolPolicy = ViewerProtocolPolicy.REDIRECT_TO_HTTPS
    }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
var myBucket Bucket

myWebDistribution := cloudfront.NewDistribution(this, jsii.String("myDist"), &DistributionProps{
	DefaultBehavior: &BehaviorOptions{
		Origin: origins.NewS3Origin(myBucket),
		AllowedMethods: cloudfront.AllowedMethods_ALLOW_ALL(),
		ViewerProtocolPolicy: cloudfront.ViewerProtocolPolicy_REDIRECT_TO_HTTPS,
	},
})
```

## Properties

- `ALLOW_ALL`: [AllowedMethods](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.AllowedMethods.html) (static) — All supported HTTP methods.

- `ALLOW_GET_HEAD`: [AllowedMethods](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.AllowedMethods.html) (static) — HEAD and GET.

- `ALLOW_GET_HEAD_OPTIONS`: [AllowedMethods](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.AllowedMethods.html) (static) — HEAD, GET, and OPTIONS.

- `methods`: string[] — HTTP methods supported.
