github.com/System-Glitch/goyave/v2@v2.10.3-0.20200819142921-51011e75d504/docs_src/src/guide/changelog.md (about) 1 --- 2 meta: 3 - name: "og:title" 4 content: "Changelog - Goyave" 5 - name: "twitter:title" 6 content: "Changelog - Goyave" 7 - name: "title" 8 content: "Changelog - Goyave" 9 --- 10 11 # Changelog 12 13 [[toc]] 14 15 ## v3.0.0 16 17 - Changed conventions: 18 - `validation.go` and `placeholders.go` moved to a new `http/validation` package. 19 - Validation rule sets are now located in a `request.go` file in the same package as the controller. 20 21 **Motivation**: *Separating the requests in another package added unnecessary complexity to the directory structure and was not convenient to use. Package naming was far from ideal with the "request" suffix. Moving requests to the same package as the controller is more intuitive and requires less imports and makes route definition cleaner and easier.* 22 23 - Validation system overhaul, allowing rule sets to be parsed only once instead of every time a request is received, giving better overall performance. This new system also allows a more verbose syntax for validation, solving the comma rule parameter value and a much easier use in your handlers. 24 25 **Motivation**: *The validation system had a lot of room for improvement when it comes to performance, as `RuleSet` were parsed every time a request was received. Moving this process out of the request life-cycle to execute it only once saves a good amount of execution time. Moreover, any handler who would want to read the rules applied to the current request needed to parse them too, which was inconvenient and not effective. With a structure containing everything you need, making middleware interacting with the request's rules is much easier.* 26 27 - Routing has been improved by changing how validation and route-specific middleware are registered. The signature of the router functions have been simplified by removing the validation and middleware parameters from `Route()`, `Get()`, `Post()`, etc. This is now done through two new chainable methods on the `Route`: `route.Validate()` and `route.Middleware()`. 28 29 **Motivation**: *In the original design, the validation parameter was included in the main route definition function because most routes were expected to be validated, which turned out not to be the case. In a typical CRUD, only the create and update actions are validated, which made the route definition dirty and filled with `nil` parameters. Separating the rules and middleware definition is more in line with their optional nature and makes routes definition cleaner and more readable, although sometimes slightly longer.* 30 31 - Log `Formatter` now receive the length of the response (in bytes) instead of the full body. 32 33 **Motivation:** *Keeping in memory the full response has an important impact on memory when sending files or large responses. Using the response content in a log formatter is also a marginal use-case which doesn't justify the performance loss described previously. It is still possible to retrieve the content of the response by writing your own chained writer.* 34 35 - Configuration system has been revamped. 36 - Added support for tree-like configurations, allowing for better categorization. Nested values can be accessed using dot-separated path. 37 - Improved validation: nested entries can now be validated too and all entries can have authorized values. Optional entries can now be validated too. 38 - Entries that are validated with the `int` type are now automatically converted from `float64` if they don't have decimal places. It is no longer necessary to manually cast `float64` that are supposed to be integers. 39 - More openness: entries can be registered with a default value, their type and authorized values from any package. This allows config entries required by a specific package to be loaded only if the latter is imported. 40 - Core configuration has been sorted in categories. This is a breaking change that will require you to update your configuration files. 41 - Entries having a `nil` value are now considered unset. 42 - Added accessors `GetInt()` and `GetFloat()`. 43 - Added `LoadFrom()`, letting you load a configuration file from a custom path. 44 - Bug fix: `config.IsLoaded()` returned `true` even if config failed to load. 45 46 **Motivation:** *Configuration was without a doubt one of the weakest and inflexible feature of the framework. It was possible to use objects in custom entries, but not for core config, but it was inconvenient because it required a lot of type assertions. Moreover, core config entries were not handled the same as custom ones, which was a lack of openness. Hopefully, this revamped system will cover more potential use-cases, ease plugin development and allow you to produce cleaner code and configuration files.* 47 48 - Rule functions don't check required parameters anymore. This is now done when the rules are parsed at startup time. The amount of required parameters is given when registering a new rule. 49 - Optimized regex-based validation rules by compiling expressions once. 50 - A significant amount of untested cases are now tested. 51 - Protect the database instance with mutex. 52 - Recovery middleware now correctly handles panics with a `nil` value. 53 - The following rules now pass if the validated data type is not supported: `greater_than`, `greater_than_equal`, `lower_than`, `lower_than_equal`, `size`. 54 - Type-dependent rules now try to determine what is the expected type by looking up in the rule set for a type rule. If no type rule is present, falls back to the inputted type. This change makes it so the validation message is correct even if the client didn't input the expected type. 55 - Fixed a bug triggering a panic if the client inputted a non-array value in an array-validated field. 56 - `response.Render` and `response.RenderHTML` now execute and write the template to a `bytes.Buffer` instead of directly to the `goyave.Response`. This allows to catch and handle errors before the response header has been written, in order to return an error 500 if the template doesn't execute properly for example. 57 - Test can now be run without the `-p 1` flag thanks to a lock added to the `goyave.RunTest` method. Therefore, `goyave.TestSuite` still **don't run in parallel** but are safe to use with the typical test command. 58 - `maxUploadSize` config entry now supports decimal places. 59 60 ## v2.10.x 61 62 ### v2.10.2 63 64 - Fixed a bug in body parsing middleware preventing json body to be parsed if a charset was provided. 65 66 ### v2.10.1 67 68 - Changed the behavior of `response.File()` and `response.Download()` to respond with a status 404 if the given file doesn't exist instead of panicking. 69 - Improved error handling: 70 - `log.Panicf` is not used anymore to print panics, removing possible duplicate logs. 71 - Added error checks during automatic migrations. 72 - `goyave.Start()` now exits the program with the following error codes: 73 - `2`: Panic (server already running, error when loading language files, etc) 74 - `3`: Configuration is invalid 75 - `4`: An error occurred when opening network listener 76 - `5`: An error occurred in the HTTP server 77 78 This change will require a slightly longer `main` function but offers better flexibility for error handling and multi-services. 79 80 ``` go 81 if err := goyave.Start(route.Register); err != nil { 82 os.Exit(err.(*goyave.Error).ExitCode) 83 } 84 ``` 85 86 - Fixed a bug in `TestSuite`: HTTP client was re-created everytime `getHTTPClient()` was called. 87 - Fixed testing documentation examples that didn't close http response body. 88 - Documentation meta improvements. 89 - Protect JSON requests with `maxUploadSize`. 90 - The server will now automatically return `413 Payload Too Large` if the request's size exceeds the `maxUploadSize` defined in configuration. 91 - The request parsing middleware doesn't drain the body anymore, improving native handler compatibility. 92 - Set a default status handler for all 400 errors. 93 - Fixed a bug preventing query parameters to be parsed when the request had the `Content-Type: application/json` header. 94 - Added a dark theme for the documentation. It can be toggled by clicking the moon icon next to the search bar. 95 96 ### v2.10.0 97 98 - Added router `Get`, `Post`, `Put`, `Patch`, `Delete` and `Options` methods to register routes directly without having to specify a method string. 99 - Added [placeholder](./advanced/localization.html#placeholders) support in regular language lines. 100 101 ## v2.9.0 102 103 - Added [hidden fields](./basics/database.html#hidden-fields). 104 - Entirely removed Gorilla mux. This change is not breaking: native middleware still work the same. 105 106 ## v2.8.0 107 108 - Added a built-in logging system. 109 - Added a middleware for access logs using the Common Log Format or Combined Log Format. This allows custom formatters too. 110 - Added three standard loggers: `goyave.Logger`, `goyave.AccessLogger` and `goyave.ErrLogger` 111 - Fixed bug: the gzip middleware now closes underlying writer on close. 112 113 ## v2.7.x 114 115 ### v2.7.1 116 117 - Changed MIME type of `js` and `mjs` files to `text/javascript`. This is in accordance with an [IETF draft](https://datatracker.ietf.org/doc/draft-ietf-dispatch-javascript-mjs/) that treats application/javascript as obsolete. 118 - Improved error handling: stacktrace wasn't relevant on unexpected panic since it was retrieved from the route's request handler therefore not including the real source of the panic. Stacktrace retrieval has been moved to the recovery middleware to fix this. 119 120 ### v2.7.0 121 122 - Added `Request.Request()` accessor to get the raw `*http.Request`. 123 - Fixed a bug allowing non-core middleware applied to the root router to be executed when the "Not Found" or "Method Not Allowed" routes were matched. 124 - Fixed a bug making route groups (sub-routers with empty prefix) conflict with their parent router when two routes having the same path but different methods are registered in both routers. 125 - Added [chained writers](./basics/responses.html#chained-writers). 126 - Added [gzip compression middleware](./basics/middleware.html#gzip). 127 - Added the ability to register route-specific middleware in `Router.Static()`. 128 129 ## v2.6.0 130 131 - Custom router implementation. Goyave is not using gorilla/mux anymore. The new router is twice as fast and uses about 3 times less memory. 132 - Now redirects to configured protocol if request scheme doesn't match. 133 - Added [named routes](./basics/routing.html#named-routes). 134 - Added `Route.GetFullURI()` and `Route.BuildURL()` for dynamic URL generation. 135 - Added `helper.IndexOfStr()` and `helper.ContainsStr()` for better performance when using string slices. 136 - Moved from GoDoc to [pkg.go.dev](https://pkg.go.dev/github.com/System-Glitch/goyave/v2). 137 - Print errors to stderr. 138 139 ## v2.5.0 140 141 - Added an [authentication system](./advanced/authentication.html). 142 - Various optimizations. 143 - Various documentation improvements. 144 - Added `dbMaxLifetime` configuration entry. 145 - Moved from Travis CI to Github Actions. 146 - Fixed a bug making duplicate log entries on error. 147 - Fixed a bug preventing language lines containing a dot to be retrieved. 148 - Fixed `TestSuite.GetJSONBody()` not working with structs and slices. 149 - Added `TestSuite.ClearDatabaseTables()`. 150 - Added `Config.Has()` and `Config.Register()` to check for the existence of a config entry and to allow custom config entries valdiation. 151 - Added `Request.BearerToken()`. 152 - Added `Response.HandleDatabaseError()` for easier database error handling and shorter controller handlers. 153 154 ## v2.4.x 155 156 ### v2.4.3 157 158 - Improved string validation by taking grapheme clusters into consideration when calculating length. 159 - `lang.LoadDefault` now correctly creates a fresh language map and clones the default `en-US` language. This avoids the default language entries to be overridden permanently. 160 161 ### v2.4.2 162 163 - Don't override `Content-Type` header when sending a file if already set. 164 - Fixed a bug with validation message placeholder `:values`, which was mistakenly using the `:value` placeholder. 165 166 ### v2.4.1 167 168 - Bundle default config and language in executable to avoid needing to deploy `$GOROOT/pkg/mod/github.com/!system-!glitch/goyave/` with the application. 169 170 ### v2.4.0 171 172 - Added [template rendring](./basics/responses.html#response-render). 173 - Fixed PostgreSQL options not working. 174 - `TestSuite.Middleware()` now has a more realistic behavior: the finalization step of the request life-cycle is now also executed. This may require your tests to be updated if those check the status code in the response. 175 - Added [status handlers](./advanced/status-handlers.html). 176 177 ## v2.3.0 178 179 - Added [CORS options](./advanced/cors.html). 180 181 ## v2.2.x 182 183 ### v2.2.1 184 185 - Added `domain` config entry. This entry is used for url generation, especially for the TLS redirect. 186 - Don't show port in TLS redirect response if ports are standard (80 for HTTP, 443 for HTTPS). 187 188 ### v2.2.0 189 190 - Added [testing API](./advanced/testing.html). 191 - Fixed links in documentation. 192 - Fixed `models` package in template project. (Changed to `model`) 193 - Added [`database.ClearRegisteredModels`](./basics/database.html#database-clearregisteredmodels) 194 195 ## v2.1.0 196 197 - `filesystem.GetMIMEType` now detects `css`, `js`, `json` and `jsonld` files based on their extension. 198 - Added maintenance mode. 199 - Can be [toggled at runtime](./advanced/multi-services.html#maintenance-mode). 200 - The server can be started in maintenance mode using the `maintenance` config option. (Defaults to `false`) 201 - Added [advanced array validation](./basics/validation.html#validating-arrays), with support for n-dimensional arrays. 202 - Malformed request messages can now be localized. (`malformed-request` and `malformed-json` entries in `locale.json`) 203 - Modified the validator to allow [manual validation](./basics/validation.html#manual-validation). 204 205 ## v2.0.0 206 207 - Documentation and README improvements. 208 - In the configuration: 209 - The default value of `dbConnection` has been changed to `none`. 210 - The default value of `dbAutoMigrate` has been changed to `false`. 211 - Added [request data accessors](./basics/requests.html#accessors). 212 - Some refactoring and package renaming have been done to better respect the Go conventions. 213 - The `helpers` package have been renamed to `helper` 214 - The server now shuts down when it encounters an error during startup. 215 - New [`validation.GetFieldType`](./basics/validation.html#validation-getfieldtype) function. 216 - Config and Lang are now protected with a `sync.RWMutex` to avoid data races in multi-threaded environments. 217 - Greatly improve concurrency. 218 - Config can now be reloaded manually. 219 - Added the [`Trim`](./basics/middleware.html#trim) middleware. 220 - `goyave.Response` now implements `http.ResponseWriter`. 221 - All writing functions can now return an error. 222 - Added the [`NativeHandler`](./basics/routing.html#native-handlers) compatibility layer. 223 - Fixed a bug preventing the static resources handler to find `index.html` if a directory with a depth of one was requested without a trailing slash. 224 - Now panics when calling `Start()` while the server is already running.