Full stack, high level framework for horizontal, model-driven application hackers.
Contrary to other frameworks that squeeze everything within two (i.e. Controller, Repository) or even a single tier, restdude provides effortless SCRUD services by generating controller, service and repository components
for you classes during application startup.
This provides an extensible 3-tier architecture without any need for boilerplate code and allows to replace and extend the generated components with your own at any time when custom or otherwise additional functionality is needed.
Besides automating SCRUD, restdude provides other conveniences with a focus on hypermedia, like dynamic generation of HATEOAS/JSON-API links and controller request mappings based on entity model relationships.
@Entity
@Table(name = "host")
@ModelResource(
path = "hosts",
apiName = "Hosts",
apiDescription = "Operations about hosts")
public class Host extends AbstractSystemUuidPersistable {
@NotNull
@Column(name = "name", nullable = false, unique = true)
private String name;
@NotNull
@Column(name = "description", length = 500, nullable = false)
private String description;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "country_id", referencedColumnName = "id")
private Country country;
@OneToMany(mappedBy = "host")
private List<Site> sites;
// other properties, getters/setters etc.
}
-
Based on the above model, restdude will generate any missing components like a Controller
, Service
and Repository
to give you the following architecture without the need for boilerplate code. You can replace or extend those with your
custom components at any time.
+-------------------------+ +---------------------+ +------------------+ Browser, App, | RESTful SCRUD | | Content negotiation | | Websockets | or other Client +-------------+-----------+ +-----------+---------+ +-------+----------+ | | | --------------------------------- | ------------------------- | ------------------- | ----------- | | | JSON+HATEOAS or JSON-API 1.x | | Network with RSQL/FIQL or URL params | STOMP | | | | | | --------------------------------- | ------------------------- | ------------------- | ----------- | | | +-------------+---------------------------+----------+ +-------+----------+ | HostController +--+ Message Broker | +--------------------------+-------------------------+ +-------+----------+ | | Restdude | | +--------------------------+------------------------------------+----------+ | HostService | +--------+--------------------+---------------------+---------------+------+ | | | | | | | | +--------+-------+ +----------+-----------+ +-------+-------+ +-----+------+ | HostRepository | | FileService (FS, S3) | | EmailService | | Misc Util | +----------------+ +----------------------+ +---------------+ +------------+
Some of the RESTful services provided out of the box for the above model:
Method | Path | Description |
---|---|---|
GET | /api/rest/hosts/{id} | Fetch the host matching the id |
GET | /api/rest/hosts/{id}/relationships/country | Fetch the country of the host matching the id |
GET | /api/rest/hosts/{id}/relationships/sites | Search the sites of the host matching the id, see search endpoints bellow for filtering etc (paged) |
GET | /api/rest/hosts?country.code=GR&name=%25startsWith | Search based on model properties using simple URL params (paged) |
GET | /api/rest/hosts?filter=country.code=in=(GR,UK);name==%25startsWith | Search based on model properties using RSQL or FIQL (paged) |
POST | /api/rest/hosts | Create a new host |
PUT | /api/rest/hosts/{id} | Update the host matching the id |
PATCH | /api/rest/hosts/{id} | Partially update the host matching the id |
DELETE | /api/rest/hosts/{id} | Delete the host matching the id |
GET | /api/rest/hosts/jsonschema | Get the JSONSchema for hosts |
The endpoints support the following content types:
application/json
and application/hal+json
for HATEOAS Resource response and plain JSON request bodies, with both being based on model structureapplication/vnd.api+json
for JSON-API-compliant request/response bodiesSee https://manosbatsis.github.io/restdude/
Restdude is distributed under the GNU Lesser General Public License