Wheel is a tool for creating and maintaining scalable and lightweight RESTful APIs. It runs through command line and generates codes (in Go Language), avoiding rework when designing the application architecture and maintenance.
- MVC
- RESTful
- JWT
- Session controller
- Middleware
- Authorization
- Users management
- ORM
- Migration
- Search engine
- Pagination
- Ordering
- Sends email
- Internationalization (I18n)
- Log
See full documentation of default features at http://wheel.unity26.org/features.html
$> go get github.com/iancoleman/strcase
$> go get github.com/jinzhu/inflection
$> go get github.com/unity26org/wheel
$> cd GOPATH/src/github.com/unity26org/wheel
$> go build -o wheel main.go
$> sudo mv wheel /usr/bin
GOPATH is where the Go packages and sources are installed
The example above, the executable file was moved to /usr/bin. But feel free to set it up to any directory you want. Just add the path to your .profile, as you see below:
export PATH=$PATH:YOUR_DESIRED_PATH
Wheel has only two options: new to create new APIs and generate to add new functionalities to your API.
Check help for more details.
wheel --help
Let's create an API for a Blog.
wheel new github.com/account_name/blog
It will output something like this:
"Go" seems installed
Checking dependences...
...
Generating new app...
created: GOPATH/src/github.com/account_name/blog
...
Your RESTful API was successfully created!
Change to the root directory using the command line below:
cd GOPATH/src/github.com/account_name/blog
Set up your database connection modifying the file config/database.yml
For more details call help:
go run main.go --help
Remember: GOPATH is where Go packages and sources are installed
Currently, Wheel has support only for Postgresql. Edit config/database.yml and set up your database connection.
To connect to your email provider edit config/email.yml and set up with your send email account.
Edit config/app.yml and set the following options:
Item | Definition |
---|---|
app_name | Your app name |
app_repository | Repository name |
frontend_base_url | URL to be used on your frontend |
secret_key | Key to encrypt passwords on database |
reset_password_expiration_seconds | After reset password, how long (in seconds) is it valid? |
token_expiration_seconds | After a JWT token is generated, how long (in seconds) is it valid? |
locales | List of available locales |
Words and phrases for internacionalization. You can add your own locales files, but remember to add to config/app.yml configuration file first.
Before running you must be sure your database schema is up to date, just run the migrate mode:
$> go run main.go --mode=migrate
Run:
$> go run main.go
Now go to http://localhost:8081 and you'll see:
{
system_message: {
type: "notice",
content: "Yeah! Wheel is working!"
}
}
See full documentation of default resources at http://wheel.unity26.org/default-resources.html
Based on the Blog API above, let's create a new CRUD.
Don't forget to call the directory where the application were generated.
cd GOPATH/src/github.com/account_name/blog
wheel g scaffold post title:string description:text published:bool user:references
It will output something like this:
"Go" seems installed
Checking dependences...
...
Generating new CRUD...
created: app/entities/post_entity.go
created: app/models/post/post_model.go
created: app/models/post/post_view.go
created: app/handlers/post_handler.go
updated: routes/routes.go
updated: db/schema/migrate.go
updated: routes/authorize.go
After any changing, don't forget to run the migrate mode:
$> go run main.go --mode=migrate
$> go run main.go
See full documentation at http://wheel.unity26.org/
Wheel is released under the MIT License.