Search Results for

    Show / Hide Table of Contents

    Class EndpointDefinition

    represents the configuration settings of an endpoint

    Inheritance
    object
    EndpointDefinition
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: FastEndpoints
    Assembly: FastEndpoints.dll
    Syntax
    public sealed class EndpointDefinition

    Constructors

    EndpointDefinition(Type, Type, Type)

    represents the configuration settings of an endpoint

    Declaration
    public EndpointDefinition(Type endpointType, Type requestDtoType, Type responseDtoType)
    Parameters
    Type Name Description
    Type endpointType
    Type requestDtoType
    Type responseDtoType

    Properties

    AllowAnyClaim

    Declaration
    public bool AllowAnyClaim { get; }
    Property Value
    Type Description
    bool

    AllowAnyPermission

    Declaration
    public bool AllowAnyPermission { get; }
    Property Value
    Type Description
    bool

    AllowedClaimTypes

    Declaration
    public List<string>? AllowedClaimTypes { get; }
    Property Value
    Type Description
    List<string>

    AllowedPermissions

    Declaration
    public List<string>? AllowedPermissions { get; }
    Property Value
    Type Description
    List<string>

    AllowedRoles

    Declaration
    public List<string>? AllowedRoles { get; }
    Property Value
    Type Description
    List<string>

    AnonymousVerbs

    Declaration
    public string[]? AnonymousVerbs { get; }
    Property Value
    Type Description
    string[]

    AntiforgeryEnabled

    Declaration
    public bool AntiforgeryEnabled { get; }
    Property Value
    Type Description
    bool

    AuthSchemeNames

    Declaration
    public List<string>? AuthSchemeNames { get; }
    Property Value
    Type Description
    List<string>

    DoNotCatchExceptions

    Declaration
    public bool DoNotCatchExceptions { get; }
    Property Value
    Type Description
    bool

    DontAutoSend

    Declaration
    public bool DontAutoSend { get; }
    Property Value
    Type Description
    bool

    DontAutoTagEndpoints

    Declaration
    public bool DontAutoTagEndpoints { get; }
    Property Value
    Type Description
    bool

    DontBindFormData

    Declaration
    public bool DontBindFormData { get; }
    Property Value
    Type Description
    bool

    EndpointAttributes

    Declaration
    public object[]? EndpointAttributes { get; }
    Property Value
    Type Description
    object[]

    EndpointSummary

    Declaration
    public EndpointSummary? EndpointSummary { get; }
    Property Value
    Type Description
    EndpointSummary

    EndpointTags

    Declaration
    public List<string>? EndpointTags { get; }
    Property Value
    Type Description
    List<string>

    EndpointType

    Declaration
    public Type EndpointType { get; init; }
    Property Value
    Type Description
    Type

    FormDataContentType

    Declaration
    public string? FormDataContentType { get; }
    Property Value
    Type Description
    string

    IdempotencyOptions

    Declaration
    public IdempotencyOptions? IdempotencyOptions { get; }
    Property Value
    Type Description
    IdempotencyOptions

    MapperType

    Declaration
    public Type? MapperType { get; }
    Property Value
    Type Description
    Type

    OverriddenRoutePrefix

    Declaration
    public string? OverriddenRoutePrefix { get; }
    Property Value
    Type Description
    string

    PolicyBuilder

    Declaration
    public Action<AuthorizationPolicyBuilder>? PolicyBuilder { get; }
    Property Value
    Type Description
    Action<AuthorizationPolicyBuilder>

    PostProcessorsList

    Declaration
    public IEnumerable<IPostProcessor> PostProcessorsList { get; }
    Property Value
    Type Description
    IEnumerable<IPostProcessor>

    PreBuiltUserPolicies

    Declaration
    public List<string>? PreBuiltUserPolicies { get; }
    Property Value
    Type Description
    List<string>

    PreProcessorsList

    Declaration
    public IEnumerable<IPreProcessor> PreProcessorsList { get; }
    Property Value
    Type Description
    IEnumerable<IPreProcessor>

    ReqDtoType

    Declaration
    public Type ReqDtoType { get; init; }
    Property Value
    Type Description
    Type

    ResDtoType

    Declaration
    public Type ResDtoType { get; init; }
    Property Value
    Type Description
    Type

    Routes

    Declaration
    public string[] Routes { get; }
    Property Value
    Type Description
    string[]

    SecurityPolicyName

    Declaration
    public string SecurityPolicyName { get; }
    Property Value
    Type Description
    string

    ThrowIfValidationFails

    Declaration
    public bool ThrowIfValidationFails { get; }
    Property Value
    Type Description
    bool

    ValidatorType

    Declaration
    public Type? ValidatorType { get; }
    Property Value
    Type Description
    Type

    Verbs

    Declaration
    public string[] Verbs { get; }
    Property Value
    Type Description
    string[]

    Version

    Declaration
    public EpVersion Version { get; }
    Property Value
    Type Description
    EpVersion

    Methods

    AdditionalVerbs(params Http[])

    specify extra http verbs in addition to the endpoint level verbs.

    Declaration
    public void AdditionalVerbs(params Http[] verbs)
    Parameters
    Type Name Description
    Http[] verbs

    AdditionalVerbs(params string[])

    specify extra http verbs in addition to the endpoint level verbs.

    Declaration
    public void AdditionalVerbs(params string[] verbs)
    Parameters
    Type Name Description
    string[] verbs

    AllowAnonymous(params Http[])

    allow unauthenticated requests to this endpoint. optionally specify a set of verbs to allow unauthenticated access with. i.e. if the endpoint is listening to POST, PUT & PATCH and you specify AllowAnonymous(Http.POST), then only PUT & PATCH will require authentication.

    Declaration
    public void AllowAnonymous(params Http[] verbs)
    Parameters
    Type Name Description
    Http[] verbs

    AllowAnonymous(string[])

    allow unauthenticated requests to this endpoint for a specified set of http verbs.

    Declaration
    public void AllowAnonymous(string[] verbs)
    Parameters
    Type Name Description
    string[] verbs

    AllowFileUploads(bool)

    enable file uploads with multipart/form-data content type

    Declaration
    public void AllowFileUploads(bool dontAutoBindFormData = false)
    Parameters
    Type Name Description
    bool dontAutoBindFormData

    set 'true' to disable auto binding of form data which enables uploading and reading of large files without buffering to memory/disk. you can access the multipart sections for reading via the FormFileSectionsAsync(CancellationToken) method.

    AllowFormData(bool)

    enable form-data submissions

    Declaration
    public void AllowFormData(bool urlEncoded = false)
    Parameters
    Type Name Description
    bool urlEncoded

    set to true to accept application/x-www-form-urlencoded content instead of multipart/form-data content.

    AuthSchemes(params string[])

    specify which authentication schemes to use for authenticating requests to this endpoint

    HINT: these auth schemes will be applied in addition to endpoint level auth schemes if there's any

    Declaration
    public void AuthSchemes(params string[] authSchemeNames)
    Parameters
    Type Name Description
    string[] authSchemeNames

    the authentication scheme names

    Claims(params string[])

    allows access if the claims principal has ANY of the given claim types

    HINT: these claims will be applied in addition to endpoint level claims if there's any

    Declaration
    public void Claims(params string[] claimTypes)
    Parameters
    Type Name Description
    string[] claimTypes

    the claim types

    ClaimsAll(params string[])

    allows access if the claims principal has ALL the given claim types

    HINT: these claims will be applied in addition to endpoint level claims if there's any

    Declaration
    public void ClaimsAll(params string[] claimTypes)
    Parameters
    Type Name Description
    string[] claimTypes

    the claim types

    Description(Action<RouteHandlerBuilder>, bool)

    describe openapi metadata for this endpoint. optionally specify whether you want to clear the default Accepts/Produces metadata.

    EXAMPLE: b => b.Accepts<Request>("text/plain")

    Declaration
    public void Description(Action<RouteHandlerBuilder> builder, bool clearDefaults = false)
    Parameters
    Type Name Description
    Action<RouteHandlerBuilder> builder

    the route handler builder for this endpoint

    bool clearDefaults

    set to true if the defaults should be cleared

    DontAutoSendResponse()

    disables auto sending of responses when the endpoint handler doesn't explicitly send a response. most useful for allowing a post-processor to handle sending of the response.

    Declaration
    public void DontAutoSendResponse()

    DontAutoTag()

    if swagger auto tagging based on path segment is enabled, calling this method will prevent a tag from being added to this endpoint.

    Declaration
    public void DontAutoTag()

    DontCatchExceptions()

    use this only if you have your own exception catching middleware. if this method is called in config, an automatic error response will not be sent to the client by the library. all exceptions will be thrown, and it would be your exception catching middleware to handle them.

    Declaration
    public void DontCatchExceptions()

    DontThrowIfValidationFails()

    disable auto validation failure responses (400 bad request with error details) for this endpoint.

    HINT: this only applies to request dto validation.

    Declaration
    public void DontThrowIfValidationFails()

    EnableAntiforgery()

    enable antiforgery token verification for an endpoint

    Declaration
    public void EnableAntiforgery()

    EndpointVersion(int, int)

    specify the version of this endpoint.

    Declaration
    public EpVersion EndpointVersion(int version, int deprecateAt = 0)
    Parameters
    Type Name Description
    int version

    the version of this endpoint

    int deprecateAt

    the version number starting at which this endpoint should not be included in swagger document

    Returns
    Type Description
    EpVersion

    Group<TEndpointGroup>()

    if this endpoint is part of an endpoint group, specify the type of the Group concrete class where the common configuration for the group is specified.

    Declaration
    public void Group<TEndpointGroup>() where TEndpointGroup : Group, new()
    Type Parameters
    Name Description
    TEndpointGroup

    the type of your Group concrete class

    Exceptions
    Type Condition
    InvalidOperationException

    thrown if endpoint route hasn't yet been specified

    Idempotency(Action<IdempotencyOptions>?)

    specify idempotency requirements for this endpoint

    Declaration
    public void Idempotency(Action<IdempotencyOptions>? options = null)
    Parameters
    Type Name Description
    Action<IdempotencyOptions> options

    the idempotency options

    Options(Action<RouteHandlerBuilder>)

    set endpoint configurations options using an endpoint builder action

    Declaration
    public void Options(Action<RouteHandlerBuilder> builder)
    Parameters
    Type Name Description
    Action<RouteHandlerBuilder> builder

    the builder for this endpoint

    Permissions(params string[])

    allows access if the claims principal has ANY of the given permissions

    HINT: these permissions will be applied in addition to endpoint level permissions if there's any

    Declaration
    public void Permissions(params string[] permissions)
    Parameters
    Type Name Description
    string[] permissions

    the permissions

    PermissionsAll(params string[])

    allows access if the claims principal has ALL the given permissions

    HINT: these permissions will be applied in addition to endpoint level permissions if there's any

    Declaration
    public void PermissionsAll(params string[] permissions)
    Parameters
    Type Name Description
    string[] permissions

    the permissions

    Policies(params string[])

    specify one or more authorization policy names you have added to the middleware pipeline during app startup/ service configuration that should be applied to this endpoint.

    HINT: these policies will be applied in addition to endpoint level policies if there's any

    Declaration
    public void Policies(params string[] policyNames)
    Parameters
    Type Name Description
    string[] policyNames

    one or more policy names (must have been added to the pipeline on startup)

    Policy(Action<AuthorizationPolicyBuilder>)

    specify an action for building an authorization requirement which should be added to all endpoints globally.

    HINT: these global level requirements will be combined with the requirements specified at the endpoint level if there's any.

    Declaration
    public void Policy(Action<AuthorizationPolicyBuilder> policy)
    Parameters
    Type Name Description
    Action<AuthorizationPolicyBuilder> policy

    th policy builder action

    PostProcessor<TPostProcessor>(Order)

    adds global post-processor to an endpoint definition which are to be executed in addition to the ones configured at the endpoint level.

    Declaration
    public void PostProcessor<TPostProcessor>(Order order) where TPostProcessor : class, IGlobalPostProcessor
    Parameters
    Type Name Description
    Order order

    set to Before if the global post-processors should be executed before endpoint post-processors. After will execute global processors after endpoint level processors

    Type Parameters
    Name Description
    TPostProcessor

    the post-processor to add

    PostProcessors(Order, params IGlobalPostProcessor[])

    adds global post-processors to an endpoint definition which are to be executed in addition to the ones configured at the endpoint level.

    Declaration
    public void PostProcessors(Order order, params IGlobalPostProcessor[] postProcessors)
    Parameters
    Type Name Description
    Order order

    set to Before if the global post-processors should be executed before endpoint post-processors. After will execute global processors after endpoint level processors

    IGlobalPostProcessor[] postProcessors

    the post-processors to add

    PostProcessors(Order, params Type[])

    adds open-generic post-processors to the endpoint definition which are to be executed in addition to the ones configured at the endpoint level.

    Declaration
    public void PostProcessors(Order order, params Type[] processorTypes)
    Parameters
    Type Name Description
    Order order

    set to Before if the global pre-processors should be executed before endpoint pre-processors. After will execute global processors after endpoint level processors

    Type[] processorTypes

    open generic post-processor types

    Exceptions
    Type Condition
    InvalidOperationException

    thrown if the supplied post-processor types are not open generic.

    PreProcessor<TPreProcessor>(Order)

    adds global pre-processor to an endpoint definition which are to be executed in addition to the ones configured at the endpoint level.

    Declaration
    public void PreProcessor<TPreProcessor>(Order order) where TPreProcessor : class, IGlobalPreProcessor
    Parameters
    Type Name Description
    Order order

    set to Before if the global pre-processors should be executed before endpoint pre-processors. After will execute global processors after endpoint level processors

    Type Parameters
    Name Description
    TPreProcessor

    the pre-processor to add

    PreProcessors(Order, params IGlobalPreProcessor[])

    adds global pre-processors to an endpoint definition which are to be executed in addition to the ones configured at the endpoint level.

    Declaration
    public void PreProcessors(Order order, params IGlobalPreProcessor[] preProcessors)
    Parameters
    Type Name Description
    Order order

    set to Before if the global pre-processors should be executed before endpoint pre-processors. After will execute global processors after endpoint level processors

    IGlobalPreProcessor[] preProcessors

    the pre-processors to add

    PreProcessors(Order, params Type[])

    adds open-generic pre-processors to the endpoint definition which are to be executed in addition to the ones configured at the endpoint level.

    Declaration
    public void PreProcessors(Order order, params Type[] processorTypes)
    Parameters
    Type Name Description
    Order order

    set to Before if the global pre-processors should be executed before endpoint pre-processors. After will execute global processors after endpoint level processors

    Type[] processorTypes

    open generic pre-processor types

    Exceptions
    Type Condition
    InvalidOperationException

    thrown if the supplied pre-processor types are not open generic.

    ResponseCache(int, ResponseCacheLocation, bool, string?, string[]?)

    specify response caching settings for this endpoint

    Declaration
    public void ResponseCache(int durationSeconds, ResponseCacheLocation location = ResponseCacheLocation.Any, bool noStore = false, string? varyByHeader = null, string[]? varyByQueryKeys = null)
    Parameters
    Type Name Description
    int durationSeconds

    the duration in seconds for which the response is cached

    ResponseCacheLocation location

    the location where the data from a particular URL must be cached

    bool noStore

    specify whether the data should be stored or not

    string varyByHeader

    the value for the Vary response header

    string[] varyByQueryKeys

    the query keys to vary by

    ResponseInterceptor(IResponseInterceptor)

    configure a response interceptor to be called before any SendAsync() methods are called. if the interceptor sends a response to the client, the SendAsync() will be ignored.

    Declaration
    public void ResponseInterceptor(IResponseInterceptor responseInterceptor)
    Parameters
    Type Name Description
    IResponseInterceptor responseInterceptor

    the response interceptor to be configured for the endpoint

    Roles(params string[])

    allows access if the claims principal has ANY of the given roles

    HINT: these roles will be applied in addition to endpoint level roles if there's any

    Declaration
    public void Roles(params string[] rolesNames)
    Parameters
    Type Name Description
    string[] rolesNames

    one or more roles that has access

    RoutePrefixOverride(string)

    specify an override route prefix for this endpoint if a global route prefix is enabled. this is ignored if a global route prefix is not configured. global prefix can be ignored by setting string.Empty

    WARNING: setting a route prefix override globally makes the endpoint level override ineffective. i.e. RoutePrefixOverride() method call on endpoint level will be ignored.

    Declaration
    public void RoutePrefixOverride(string routePrefix)
    Parameters
    Type Name Description
    string routePrefix

    route prefix value

    Summary(EndpointSummary)

    provide a summary/description for this endpoint to be used in swagger/ openapi

    Declaration
    public void Summary(EndpointSummary endpointSummary)
    Parameters
    Type Name Description
    EndpointSummary endpointSummary

    an endpoint summary instance

    Summary(Action<EndpointSummary>)

    provide a summary/description for this endpoint to be used in swagger/ openapi

    Declaration
    public void Summary(Action<EndpointSummary> endpointSummary)
    Parameters
    Type Name Description
    Action<EndpointSummary> endpointSummary

    an action that sets values of an endpoint summary object

    Summary<TRequest>(Action<EndpointSummary<TRequest>>)

    provide a summary/description for this endpoint to be used in swagger/ openapi

    Declaration
    public void Summary<TRequest>(Action<EndpointSummary<TRequest>> endpointSummary) where TRequest : notnull
    Parameters
    Type Name Description
    Action<EndpointSummary<TRequest>> endpointSummary

    an action that sets values of an endpoint summary object

    Type Parameters
    Name Description
    TRequest

    Tags(params string[])

    specify one or more string tags for this endpoint so they can be used in the exclusion filter during registration.

    HINT: these tags will be applied in addition to endpoint level tags if there's any

    TIP: these tags have nothing to do with swagger tags!

    Declaration
    public void Tags(params string[] endpointTags)
    Parameters
    Type Name Description
    string[] endpointTags

    the tag values to associate with this endpoint

    Throttle(int, double, string?)

    rate limit requests to this endpoint based on a request http header sent by the client.

    Declaration
    public void Throttle(int hitLimit, double durationSeconds, string? headerName = null)
    Parameters
    Type Name Description
    int hitLimit

    how many requests are allowed within the given duration

    double durationSeconds

    the frequency in seconds where the accrued hit count should be reset

    string headerName

    the name of the request header used to uniquely identify clients. header name can also be configured globally using app.UseFastEndpoints(c=> c.Throttle...) not specifying a header name will first look for 'X-Forwarded-For' header and if not present, will use HttpContext.Connection.RemoteIpAddress.

    Validator<TValidator>()

    validator that should be used for this endpoint

    Declaration
    public void Validator<TValidator>() where TValidator : IValidator
    Type Parameters
    Name Description
    TValidator

    the type of the validator

    In this article
    Back to top Developed by Đĵ ΝιΓΞΗΛψΚ and contributors / Licensed under MIT / Website generated by DocFX