Skip to content

Commit

Permalink
Merge pull request #43 from innFactory/doc
Browse files Browse the repository at this point in the history
doc: add some docs
  • Loading branch information
jona7o authored Oct 17, 2022
2 parents 49be9fd + 265526a commit 0d1e43b
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
![](docs/smithy4play.png)
![GitHub last commit](https://img.shields.io/github/last-commit/innFactory/smithy4play)
[![Scala Build and Test CI](https://github.com/innFactory/smithy4play/actions/workflows/build.yml/badge.svg)](https://github.com/innFactory/smithy4play/actions/workflows/build.yml)

smithy4play brings the smithy4s http4s route gen to your play server and generates your routes for you
---
# Smithy4Play

smithy4play is a routing gernator for the play2 framework based on [smithy4s](https://github.com/disneystreaming/smithy4s). Just write your smithy API definition and the plugin will generate everything you need for play2 framework usage.

**Installation**
---

## QuickStart
### Add smithy4play to your project

plugins.sbt

```scala
Expand All @@ -28,12 +32,12 @@ build.sbt
libraryDependencies += "de.innfactory" %% "smithy4play" % "latestVersion")
```

**Usage**
---
- define controllers in smithy files
### Usage

- define your controllers in smithy files
- use smithy4s codegen (sbt compile)

Server
**Server**
- create controller scala class
- extend your Controller with the generated Scala Type and smithy4play Type ContextRoute

Expand All @@ -51,7 +55,8 @@ class PreviewController @Inject(
}
}
```
Client

**Client**
- create Client Class
- extend the Client with the generated Scala Type and smithy4play Type ClientResponse
- implement a smithy4play RequestClient that handles the request
Expand All @@ -76,9 +81,11 @@ previewControllerClient.preview()
```
For a further examples take a look at the smithy4playTest project.

**Routing**
---
Autorouting
## Routing

You can choose between autorouting or selfbinding.

### Autorouting

- Annotate your controller with ```@AutoRouting```
- add ```scalacOptions += "-Ymacro-annotations"``` to your build.sbt settings to enable macro annotations
Expand All @@ -92,7 +99,7 @@ Autorouting
smithy4play.autoRoutePackage = "your.package.name"
```

Selfbinding
### Selfbinding

- Create a ApiRouter class and inject your controller

Expand All @@ -118,3 +125,6 @@ class ApiRouter @Inject()(
-> / api.ApiRouter
```

## Credits:

[innFactory ❤️ Open Source](https://innfactory.de)

0 comments on commit 0d1e43b

Please sign in to comment.