Documents the changes that may be required when upgrading to a newer component version.
The #annotation_configurations getter on ATH::Action and ATH::Controller::ParameterMetadata has been removed.
Inject and use the new ATH::AnnotationResolver service to access the annotations:
Before:
# Action
request.action.annotation_configurations
# Parameter
parameter.annotation_configurationsAfter:
# Action
@annotation_resolver.action_annotations(request)
# Parameter
@annotation_resolver.action_parameter_annotations(request, parameter.name)The following types have been extracted from the framework component into the dedicated http component.
Any references will need their namespace updated from Athena::Framework (ATH) to Athena::HTTP (AHTTP):
RequestResponseResponseHeadersRedirectResponseStreamedResponseBinaryFileResponseParameterBagHeaderUtilsIPUtilsRequestStoreAbstractFileUploadedFileRequestMatcherRequestMatcher::AttributesRequestMatcher::HeaderRequestMatcher::HostnameRequestMatcher::MethodRequestMatcher::PathRequestMatcher::QueryParameterException::ConflictingHeadersException::SuspiciousOperationException::RequestExceptionInterfaceException::FileException::FileNotFoundException::FileSizeLimitExceededException::Logic
The following types have been extracted from the framework component into the dedicated http_kernel component.
Any references will need their namespace updated from Athena::Framework (ATH) to Athena::HTTPKernel (AHK):
ActionActionBaseController::ArgumentResolverController::ArgumentResolverInterfaceController::ParameterMetadataController::ValueResolvers::DefaultValueController::ValueResolvers::RequestController::ValueResolvers::RequestAttributeErrorRendererErrorRendererInterfaceEvents::ActionEvents::ExceptionEvents::RequestEvents::RequestAwareEvents::ResponseEvents::SettableResponseEvents::TerminateEvents::ViewException::BadGatewayException::BadRequestException::ConflictException::ForbiddenException::GoneException::HTTPExceptionException::LengthRequiredException::LogicException::MethodNotAllowedException::NotAcceptableException::NotFoundException::NotImplementedException::PreconditionFailedException::ServiceUnavailableException::TooManyRequestsException::UnauthorizedException::UnprocessableEntityException::UnsupportedMediaTypeListeners::ErrorListeners::Routing
The AHTTP::Request#action getter used to access the matched ATH::Action instance has been removed.
The action is now stored within the request's attributes as "_action" and must be accessed via:
request.attributes.get("_action", AHK::ActionBase)#get? may be used in place of #action? if it's not guaranteed the action exists.
The ATHA::QueryParam annotation applied to the controller action is replaced with the ATHA::MapQueryParameter annotation applied directly to the parameter.
Before:
class ExampleController < ATH::Controller
@[ARTA::Get("/")]
@[ATHA::QueryParam("page")]
def index(page : Int32) : Int32
page
end
endAfter:
class ExampleController < ATH::Controller
@[ARTA::Get("/")]
def index(@[ATHA::MapQueryParameter] page : Int32) : Int32
page
end
endSee the API Docs for more information.
The ATHA::RequestParam annotation that allowed mapping x-www-form-urlencoded form data within the request body to particular controller action parameters has been removed in favor of ATHR::RequestBody, which now supports deserializing form data request bodies into a DTO type.
Before:
class ExampleController < ATH::Controller
@[ARTA::Post("/login")]
@[ATHA::RequestParam("username")]
@[ATHA::RequestParam("password")]
def login(username : String, password : String) : Nil
# ...
end
endAfter:
record LoginDTO, username : String, password : String do
include URI::Params::Serializable
end
class ExampleController < ATH::Controller
@[ARTA::Post("/login")]
def login(@[ATHA::MapRequestBody] login : LoginDTO) : Nil
# ...
end
endThis provides better consistency and additional features such as adding validation constraints to the request parameters.
The namespace exception types live in has changed from ATH::Exceptions to ATH::Exception.
Any usages of framework exception types will need to be updated.
If using a rescue statement with a parent exception type, either from the framework component or Crystal stdlib, double check it to ensure it'll still rescue what you are expecting it will.
Previously if you had a value resolver using the configuration macro:
struct Multiply
include ATHR::Interface
configuration This
# ...
endThe This configuration would be scoped to the Multiply namespace, i.e. @[Multiply::This].
Scoping is now handled separately, meaning the same resolver could define multiple configurations to an entirely different namespace.
If you wish to retain the same behavior, provide the FQN to the configuration macro: configuration Multiply::This.
If you wish to move the configuration to another namespace, prefix the FQN with ::: configuration ::MyApp::Annotations::Multiply.
This change is a pretty fundamental change and cannot really be easily captured in this upgrading guide. Instead, take a moment to review the updated Configuration section in the getting started guide.
At a high level, the .configure calls have been replaced with ATH.configure that handles both configuration and parameters.