Class MethodNotAllowedError
- Namespace
- Trellis
- Assembly
- Trellis.Results.dll
Represents a method not allowed error when the HTTP method is not supported for the target resource. Maps to HTTP 405 Method Not Allowed.
public sealed class MethodNotAllowedError : Error, IEquatable<Error>
- Inheritance
-
MethodNotAllowedError
- Implements
- Inherited Members
- Extension Methods
Examples
Error.MethodNotAllowed("DELETE is not supported on this resource.", ["GET", "PUT"])
Remarks
Per RFC 9110 §15.5.6, a 405 response MUST include an Allow header
listing the methods the target resource currently supports.
The AllowedMethods property carries this information so that
Trellis response mappers can emit the required header automatically.
Constructors
MethodNotAllowedError(string, IReadOnlyList<string>, string, string?)
Initializes a new instance of the MethodNotAllowedError class.
public MethodNotAllowedError(string detail, IReadOnlyList<string> allowedMethods, string code, string? instance = null)
Parameters
detailstringDescription of why the method is not allowed.
allowedMethodsIReadOnlyList<string>The HTTP methods the resource supports.
codestringThe error code identifying this type of error.
instancestringOptional identifier for the resource.
Properties
AllowedMethods
Gets the HTTP methods that the target resource currently supports.
This is emitted as the Allow response header per RFC 9110 §15.5.6.
public IReadOnlyList<string> AllowedMethods { get; }