Upgrading To v1.10 From v1.9
Exciting New Features ๐
Enhancements ๐
- Optimize HTTP startup mode(1.10.0)
- Optimize GRPC startup mode(1.10.0)
- Add configuration to control log output to console(1.10.0)
- Request modify and add methods(1.10.0)
- Queue support delayed dispatching(1.10.0)
- The Connection in ORM supports set table prefix and singular(1.10.0)
- Add docker-compose.yml file(1.10.0)
- Optimize Orm(1.10.0)
- Support multiple SQL in migration file(1.10.0)
- Add minio driver for File Storage(1.10.0)
- contracts/http add status mapping of net/http(1.10.0)
Breaking Changes ๐
- APP_KEY required(1.10.0)
- Add ctx parameter to the methods under Form Request(1.10.0)
- facades.Auth.Parse adds payload returns(1.10.0)
- Some methods of Orm add new return values(1.10.0)
Upgrade Guide
Estimated Upgrade Time: 20 Minutes
Updating Dependencies
Update dependencies in the go.mod
file:
go get -u github.com/goravel/framework@v1.10.0 && go mod tidy
Encryption
Version: v1.10.0
Add facades.Crypt
:
- add
&crypt.ServiceProvider{}
to theproviders
item in the config/app.go file;
Hashing
Version: v1.10.0
Add facades.Hash
:
add
&hash.ServiceProvider{}
to theproviders
item in the config/app.go file;Add config/hashing.go file;
Add Rate Limiting For Routing
Version: v1.10.0
Optimize HTTP startup mode
Version: v1.10.0
- Add
config/http.go
configuration, For Detail; - The
facades.Route.Run
method no longer needs to pass parameters, by default usehttp.host
andhttp.port
(you don't need to modify the code, it's backward compatible); - The
facades.Route.RunTLS
method no longer needs to pass parameters, by default usehttp.tls.host
,http.tls.port
,http.tls.ssl.cert
andhttp.tls.ssl.key
, if you are using it, you need to modify the code; - Add
facades.Route.RunTLSWithCert
method, For Detail; - Move
app.url
,app.host
tohttp.url
,http.host
;
Optimize GRPC startup mode
Version: v1.10.0
The facades.Grpc.Run
method no longer needs to pass parameters, by default use grpc.host
and grpc.port
(you don't need to modify the code, it's backward compatible);
Add configuration to control log output to console
Version: v1.10.0
Add print
configuration to single
, daily
channel in the config/logging.go
file, it can control log output to console, For Detail;
Request modify and add methods
Version: v1.10.0
- The
Input
method is changed from only getting routing parameters to getting data according to the following order:json
,form
,query
,route
ใNote:json
can only get one-dimensional data, otherwise it will return empty; - Add
Route
method to replace the originalInput
method; - The default value of
Query
andForm
methods are modified to be unnecessary; - Add methods as shown below:
Method | Action |
---|---|
Route | Retrieving An Route Value |
RouteInt | Retrieving An Route Value |
RouteInt64 | Retrieving An Route Value |
QueryInt | Retrieving Input From The Query String |
QueryInt64 | Retrieving Input From The Query String |
QueryBool | Retrieving Input From The Query String |
InputInt | Retrieving An Input Value |
InputInt64 | Retrieving An Input Value |
InputBool | Retrieving An Input Value |
Json | Retrieving Json |
Queue support delayed dispatching
Version: v1.10.0
Add Delay
method, For Detail
The Connection in ORM supports set table prefix and singular
Version: v1.10.0
Model
supports specify table name, For Detail;- Add new keys to
connection
ofconfig/database.go
:
prefix
: Set prefix for table name; singular
: Set the table name to use singular or plural;
Add docker-compose.yml file
Version: v1.10.0
You can quickly start the service with the following command:
docker-compose build
docker-compose up
Optimize Orm
Version: v1.10.0
- Add the following methods:
Functions | Action |
---|---|
FirstOr | Query or return data through callback |
FirstOrNew | Retrieving Or New Models |
FirstOrFail | Not Found Error |
UpdateOrCreate | Update or create |
- An error was reported like this before, but now it's supported:
query := facades.Orm.Query()
query = query.Where()
Support multiple SQL in migration file
Version: v1.10.0
Previously, only one SQL statement was supported in the migration file, but now multiple statements are supported.
Add minio driver for File Storage
Version: v1.10.0
Add minio configuration, For Detail.
contracts/http add status mapping of net/http
Version: v1.10.0
You can use status codes such as http.StatusOK
directly in controller without importing net/http
.
APP_KEY required
Version: v1.10.0
The APP_KEY
in the .env
file is changed to required, you can run command to generate the APP_KEY: go run . artisan key:generate
.
Add ctx parameter to the methods under Form Request
Version: v1.10.0
Add ctx http.Context
parameter to the methods under Form Request: Rules
, Messages
, Attributes
, PrepareForValidation
, allows you to do more custom configurations.
facades.Auth.Parse add payload returns
Version: v1.10.0
err := facades.Auth.Parse(ctx, token)
change to payload, err := facades.Auth.Parse(ctx, token)
, through payload
you can get:
Guard
: Current Guard;Key
: User flag;ExpireAt
: Expire time;IssuedAt
: Issued time;
Some methods of Orm add new return values
Version: v1.10.0
The following methods add *Result
return value to get the number of affected rows:
res, err := query.Delete(&user)
res, err := query.Exec(fmt.Sprintf("DELETE FROM users where id = %d", user.ID))
res, err := query.ForceDelete(&User{})
res, err := query.Updates(User{Avatar: "avatar"})
// Affected rows
num := res.RowsAffected