This project is part of my personal portfolio, so, I'll be happy if you could provide me any feedback about the project, code, structure or anything that you can report that could make me a better developer!
Email-me: [email protected]
Connect with me at LinkedIn.
- Generate hateoas struct for restfull level
go get github.com/booscaaa/go-hateoas
import "github.com/booscaaa/go-hateoas/hateoas"
mockStruct := struct {
ID int
Make string
Model string
Mileage int
hateoas.Hateoas
}{
ID: 10,
Make: "Ford",
Model: "Taurus",
Mileage: 200000,
}
hateoas.Generate(&mockStruct, "vehicle", "http://localhost:3000")
The output:
{
"ID": 10,
"Make": "Ford",
"Model": "Taurus",
"Mileage": 200000,
"_links": [
{
"href": "http://localhost:3000/vehicle",
"method": "POST",
"doc": "http://localhost:3000/doc/index.html#/vehicle/post_vehicle",
"key": "new"
},
{
"href": "http://localhost:3000/vehicle/11",
"method": "GET",
"doc": "http://localhost:3000/doc/index.html#/vehicle/get_vehicle",
"key": "next"
},
{
"href": "http://localhost:3000/vehicle/9",
"method": "GET",
"doc": "http://localhost:3000/doc/index.html#/vehicle/get_vehicle",
"key": "prev"
}
],
"_embeded": [
{
"href": "http://localhost:3000/vehicle/10",
"method": "GET",
"doc": "http://localhost:3000/doc/index.html#/vehicle/get_vehicle"
},
{
"href": "http://localhost:3000/vehicle/10",
"method": "PUT",
"doc": "http://localhost:3000/doc/index.html#/vehicle/put_vehicle__id_"
},
{
"href": "http://localhost:3000/vehicle/10",
"method": "DELETE",
"doc": "http://localhost:3000/doc/index.html#/vehicle/delete_vehicle__id_"
}
]
}
You can send how many PR's do you want, I'll be glad to analyze and accept them! And if you have any question about the project...
Email-me: [email protected]
Connect with me at LinkedIn
Thank you!
This project is licensed under the MIT License - see the LICENSE.md file for details