Skip to content

Commit b65d333

Browse files
Nolan SullivanNolan Sullivan
authored andcommitted
Updating readme in preparation of OSS release.
1 parent 6cda547 commit b65d333

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
1-
# speakeasy-example-rest-service-go
1+
# The RESTful API Template Project [Golang]
2+
3+
- Website: https://www.speakeasyapi.dev/
4+
- Twitter: https://twitter.com/speakeasydev
5+
6+
![Speakeasy logo and mascot](https://storage.cloud.google.com/speakeasy-design-assets/speakeasy-docs-logo.png)
7+
8+
## How To Use This Repo
9+
10+
This repo is intended to be used by Golang developers seeking to understand the building blocks of a simple and well-constructed REST API service. We have built a simple CRUD API which exhibits the characteristics we expect our own developers to apply to the APIs we build at Speakeasy:
11+
12+
- **Entity-based**: The resources available should represent the domain model. Each resource should have the CRUD methods implemented (even if not all available to API consumers). In our template, we have a single resource defined (users.go). However other resources could be easily added by copying the template and changing the logic of the service layer.
13+
- **Properly Abstracted**: The Transport, service, and data layers are all cleanly abstracted from one another. This makes it easy to make apply updates to the API endpoints
14+
- **Consistent**: It's important that consumers of a service have guaranteed consistency across the entire range of API endpoints and methods. In this service, responses are consistently formatted whether successfully returning a JSON object or responding with an error code. All the service's methods use shared response (http.go) and error (errors.go) handler functions to ensure consistency.
15+
- **Tested**: We believe that a blend of unit and integration testing is important for ensuring that the service maintains its contract with consumers. The service repo therefore contains a collection of unit and integration tests for the various layers of the service.
16+
- **Explorable**: It is important for developers to be able to play with an endpoint in order to understand it. We have provided Postman collections for testing out the REST endpoints exposed by the service. That's why there is a `Bootstrap Users` collection that can be run using the `Run collection` tool in Postman that will create 100 users to test the search endpoint with.
17+
18+
This repo can serve as an educational tool, or be used as a foundation upon which developers can build their own basic API scaffolding to turn API development into a consistent and marignally easier activity.
219

320
## Getting Started
421

522
### Prerequisites
623

7-
* Go 1.18 (though should be backwards compatible with earlier versions)
24+
- Go 1.18 (should still be backwards compatible with earlier versions)
825

926
### Running locally
1027

1128
1. From root of the repo
12-
2. Run `go mod download` to install dependencies
13-
3. Run `docker-compose up -d postgres` to run the postgres dependency
14-
4. Run `go run cmd/server/main.go` will start the server on port 8080
29+
2. Run `docker-compose up` will start the dependencies and server on port 8080
1530

1631
### Running via docker
1732

@@ -20,14 +35,11 @@
2035

2136
### Postman
2237

23-
I have provided Postman collections for testing out the REST endpoints exposed by the service.
24-
There is a `Bootstrap Users` collection that can be run using the `Run collection` tool in Postman that will create 100 users to test the search endpoint with.
25-
2638
The collections will need an environment setup with `scheme`, `port` and `host` variables setup with values of `http`, `8080` and `localhost` respectively.
2739

2840
### Run tests
2941

30-
The service contains a collection of unit and integration tests for testing the various layers of the service. Some of the integration tests use docker to spin up dependencies on demand (ie a postgres db) so just be aware that docker is needed to run the tests.
42+
Some of the integration tests use docker to spin up dependencies on demand (ie a postgres db) so just be aware that docker is needed to run the tests.
3143

3244
1. From root of the repo
3345
2. Run `go test ./...`

0 commit comments

Comments
 (0)