- Updated dependancies
- Now compatible with (and requires) Rack 3.x
- No longer escapes "+" into space characters
- Fixed issue where routes with a
media_typecondition were prioritised over those without for HTTP requests accepting "/"
- Now requiring CGI instead of URI library as per v1.0.1 deprecation fixes.
- Fixed Ruby 2.7 deprecations
- Updated all dependencies. Ready for 1.0.0 release.
- Log level now defaults to :warn for every environment except development, which defaults to :debug
- Added
dispatchedcondition which performs a similar role to the recently removedhandledcondition.
- APP_ENV now preferred over RACK_ENV for setting the environment.
- Updated core dependencies.
- Refactored
processmethod. Now namedrespond, and breaks out to other methods. The logic surrounding filters and halting has also been modified, as is now more intuitive in my opinion. - Removed
@_handledinstance variable, and the relatedhandledcondition. redirectmethod signature has changed.- Scorched now depends on Rack 2.0 or above.
- Fixed logic surrounding when a requested is considered "handled" (i.e. matched and dispatched) and exceptions that are raised after dispatch. In simpler terms, the
failed_conditioncondition now has better logic in the event of an exception.
- Fixed issue with
failed_conditioncondition resulting inNoMethodError: undefined method '[]' for nil:NilClass
- Added symbol matchers, which are basically just named regex. Only two symbol matchers included by default,
:numericand:alpha_numeric. It's intended that users add their own as per their applications requirements. E.g.symbol_matchers[:article_id] = /[a-f][0-9]{4}/. A symbol matcher can optionally take a two-element array, where the first element is the regex, and the second is a proc for the sake of coercing the matched value into the desired form, such as an integer. - Changed Rack::Logger to Rack::CommonLogger.
- Query string is now preserved when stripping trailing slashes with
config[:strip_trailing_slash] = :redirect, e.g./search/?query=catsnow becomes/search?query=catsinstead of just/search. absolutemethod now returns as-is anything not starting with a forward slash, e.g.absolute("./view") => "./view"- Improved performance by caching the Rack::Builder instance for each controller.
- Improved performance by caching data associated with Scorched::Options#to_hash.
- Now using scorched-accept for accept header parsing and logic, which fixes issues with the
:media_typecondition. - Exceptions caught by Scorched are now assigned to env['rack.exception'].
- Implemented
respond_to_missing?on Scorched::Controller.
- The
redirectmethod now passes the given URL throughabsolute. - The error page filter now always runs at the end-point controller so
:show_http_error_pagesbehaves as expected when overriden in sub-controllers.
- Named captures have changed again. The values are now passed as arguments to route proc's in favor of using the new
capturesconvenience method for accessing named arguments as a hash. - The
:redirectoption for:strip_trailing_slashesno longer cause a redirection loop when the request path is set to two or more forward slashes, e.g. '//' - Changed default value of
render_defaults[:tilt]to{default_encoding: 'UTF-8'}. This defaults Tilt to using UTF-8 for loading template files, which is desirable 99% of the time. - The
actionmethod has been split out into two new methods,processanddispatch. This provides the oppurtunity to override the dispatch logic where more control is needed over how mapping targets are invoked. :failed_conditioncondition now takes into account whether any mapping has actually handled the request. This allows for example, the correct status to be set when a mapping has been matched, but haspassed the request.
- After filters are now still processed when a request is halted. This restores the original behaviour prior to version 0.8. This fixes an issue where halting the request after setting flash session data would cause the request to bomb-out.
- As an extension of the change above, filters can now be marked as forced using the new
forceoption, which if true, means the filter will run even if the request is halted within another filter (including within another forced filter). This ensures a particular filter is run for every request. This required changing the public interface for the filter method. The sugar methods before, after, and error have remained backwards compatible. - Named captures are now passed to route proc's as a single hash argument. The previous behaviour was an oversight.
- Halting within an error filter is now swallowed if the error filter is invoked by an error raised in a before or after filter.
- The
controllerhelper can now be used to map predefined controllers simply by omitting the block, which is now optional. This a more convenient means of mapping controllers as compared to the more barebonesmapmethod. logmethod now returns the log object. Method arguments are also now optional, meaning you can use the more natural logger interface if you prefer, e.g.log.info "hello".
- The behaviour of wildcards
*and**(and their named equivalents) have been reverted to their original behaviour of matching one or more characters, instead of zero or more. This means/*will no longer match/. Adding a question mark directly after a wildcard will have that wildcard match zero or more character, instead of one or more. So the pattern/*?will match both/and/about.
- Redirects now use a 303 or 302 HTTP status code by default, depending on HTTP version (similar logic to Sinatra). Trailing slash redirects (triggered by :strip_trailing_slash) still uses a 307 status.
- Fixes an issue introduced in v0.16 where joining
SCRIPT_NAMEandPATH_INFOwould sometimes produce a path with two forward slashes, and a related issue wherePATH_INFOwould sometimes be missing a leading forward slash when it should have had one. - Mappings are now sorted by the best matching
media typein addition to the existing logic that included definition order and priority. This required that mappings be sorted at request-time rather than at the time they're mapped. Note, because of limitations ofrack-accept, this doesn't completely respect the HTTP spec when it comes to prioritising which media type to serve for a given request. Full support for the HTTP spec is intended for a future release. - File path references to views are now joined to the view directory using #expand_path. This allows views to be specified with an absolute path (effectively ignoring the view directory), and better support for relative paths.
- A copy of the Rack env hash is now handed off to sub-controllers and other Rack-callable objects, with
PATH_INFOandSCRIPT_NAMEnow set to appropriate values, bring Scorched inline with the Rack specification. This differs from the original behaviour which was to just forward on the original env hash unmodified. - URL helper method
absoluteandurlnow use the new env propertyscorched.root_pathas their base path, rather thanSCRIPT_NAME. - Helpers for HTTP methods
linkandunlinkhave been added.
- Route DSL methods (
route,get,post, ...) now accept an array of patterns as the pattern argument. Each pattern is defined as a separate mapping, sharing the same target proc. This provides a cleaner and more efficient solution to simply wrapping a route definition within a loop. - URI unescaping has been implemented for
Scorched::Request#unmatched_path. This modification directly affects route matching. Previously, routes were matched against the escaped path, e.g./this%20has%20spaces. Routes are now matched against the unescaped form/this has spaces. The only exception is the escaped forward-slash%2Fand percent sign%25which remain unaltered for the fact their unescaped form as special meaning which you wouldn't be able to disambiguate. It's however safe to unescape the path a second time to resolve these characters.
- If a matched mapping passes the request and there are no other matching mappings, a 404 status is now set by default, rather than a 200 status.
- Renamed
matchedcondition tohandledto be less ambiguous.
- Added
content_typecondition, corresponding to theContent-Typerequest header. - Reverted rogue commit containing experimental debugging logging that I didn't plan to merge. Fixes issue #12.
- Halt can now take an optional response body (typically a string).
- Controller now returns a valid rack array, rather than a Scorched::Response.
- Fixed an issue where subsequent nested render calls would render the default layout, which they shouldn't (issue #9).
- Bumped Tilt dependancy to v1.4 and removed work-around for Tilt encoding issue.
- Route wildcards '*' and '**' (and their named equivalents) now match zero or more characters, instead of one or more. This means
/*will now match both/and/aboutfor example. - Conditions can now be inverted by appending an exclamation mark to the condition, e.g.
method!: 'GET'matches all HTTP methods, excluding GET. - While not strictly Scorched related, one planned feature for Scorched was to implement a simple form population mechanism. This has instead been implemented as a stand-alone project, Formless, which can be used with any framework or application, including Scorched.
- Route matching internals have been refactored.
- Match information is now stored in the
Matchstruct for better formalisation. matchesmethod no longer has a short-circuit option, and now returns all mappings that match the URL, regardless of whether their conditions passed. It also now caches the set of matches which are returned on subsequent calls.- The first failed condition (if any) is stored in the
Matchstruct as:failed_condition. This allows one to change the response in an after block depending on what condition failed. For example, proper status codes can be set depending on the failed condition. - Response status defaults to 403 if one or more mappings are matched, but their conditions do not pass. The existing behaviour was to always return 404.
- Match information is now stored in the
- Added
:proccondition which takes one or more Proc objects, allowing custom conditions to be added on-the-fly. - Added
:matchedcondition. When a controller delegates the request to a mapping, it's considered to be matched. - Added
:failed_conditioncondition. If one or more mappings are matched, but they're conditions do not pass, the first failed condition of the first matched mapping is considered thefailed_conditionfor the request. - Added
:configcondition which takes a hash, each element of which must match the value of the corresponding config option. - Renamed
:methodscondition to:methodfor consistency sake. - Added default error message for all empty responses with a HTTP status code between 400 and 599, inclusive.
Scorched::Collectionnow merges parent values onto the beginning of self, rather than the end.- To compensate for the previous change, an
append_parentaccessor added toScorched::Collectionto allow after filters to run in the correct order, executing inner filters before outer filters. - Added
:show_http_error_pagesconfig option. If true, it shows the Scorched HTTP error pages. Defaults to false. - Filters have been added to set the appropriate HTTP status code for certain failed conditions, such as returning
405 Method Not Allowedwhen for example, a POST is made to a URL that only accepts GET requests.
- Refactored
rendermethod:- All Scorched options are now keyword arguments, including
:localswhich was added as a proper render option. - Scorched options are no longer passed through to Tilt.
:tiltoption added to allow options to be passed directly to Tilt, such as:engine- Unrecognised options are still passed through to Tilt for convenience.
- All Scorched options are now keyword arguments, including
- Added template caching using Tilt::Cache.
- Added
:cache_templatesconfig option. Defaults to true except for development.
- Added
- Changed
controllermethod signature to accept an optional URL pattern as the first argument. - Implemented a pass mechanism to short-circuit out of the current match and invoke the next match.
- Added
:auto_passconfiguration option. When true, if none of the controller's mapping match the request, the controller willpassback to the outer controller without running any filters. - Sub-controllers generated with the
controllerhelper are automatically configured with:auto_passset totrue. This makes inline sub-controllers even more useful for grouping routes.
- Logging preparations made. Now just have to decide on a logging strategy, such as what to log, how verbose the messages should be, etc.
- Environment-specific defaults added. The environment variable
RACK_ENVs used to determine the current environment.- Non-Development
config[:static_dir] = false* Developmentconfig[:show_exceptions] = true*config[:logger] = Logger.new(STDOUT)* Add developer-friendly 404 error page. This is implemented as an after filter, and won't have any effect if the response body is set.
- Non-Development
absolutemethod now returns forward slash if script name is empty.
view_configoptions hash renamed torender_defaults`ch better reflects its function.
- Minor modification to routing to make it behave as documented regarding matching a forward slash directly after or at the end of the matched path.
- Response content-type now defaults to "text/html;charset=utf-8", rather than empty.
- Added URL helpers, #absolute and #url
- Render helper now loads files itself as Tilt still has issues with UTF-8 files.
- Implemented view rendering using Tilt.
- Added session method for convenience, and implemented helper for flash session data.
- Added cookie helper for conveniently setting, retrieving and deleting cookies.
- Static file serving actually works now
- Custom middleware Scorched::Static serves as a thin layer on top of Rack::File.
- Added specs for each configuration option.
- Using Ruby 2.0 features where applicable. No excuse not to be able to deploy on 2.0 by the time Scorched is ready for production.
- Keyword arguments instead of
*argsombined withHash === args.last* Replaced instances ofFILEith__dir__Added expected Rack middleware, Rack::MethodOverride and Rack::Head.
- Keyword arguments instead of
- Make filters behave like middleware. Inheritable, but are only executed once.
- Improved implementation of Options and Collection classes
- Basic request handling and routing
- String and Regex URL matching, with capture support
- Implemented route conditions
- Added HTTP method condition which the route helpers depend on.
- Added route helpers
- Implemented support for sub-controllers
- Implement before and after filters with proper execution order.
- Configuration inheritance between controllers. This has been implemented as the Options class.
- Mechanism for including Rack middleware.
- Added more route conditions e.g. content-type, language, user-agent, etc.
- Provide means to
haltrequest.- Added redirect helping for halting and redirecting request
- Mechanism for handling exceptions in routes and before/after filters.
- Added static resource serving. E.g. public folder.