Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stefanvanburen/petstore
πΆπ±πͺ
https://github.com/stefanvanburen/petstore
buf connect connect-go protobuf
Last synced: about 1 month ago
JSON representation
πΆπ±πͺ
- Host: GitHub
- URL: https://github.com/stefanvanburen/petstore
- Owner: stefanvanburen
- Created: 2022-08-27T18:11:44.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-16T14:00:10.000Z (2 months ago)
- Last Synced: 2024-09-17T16:23:36.415Z (2 months ago)
- Topics: buf, connect, connect-go, protobuf
- Language: Go
- Homepage: https://petstore.fly.dev
- Size: 128 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PetStore πΆπ±πͺ
This is a Go server that implements the [PetStoreService API](https://buf.build/acme/petapis/docs/main:pet.v1#pet.v1.PetStoreService).
It's hosted on [fly.io](https://fly.io), at [petstore.fly.dev](https://petstore.fly.dev).
The source code is at [github.com/stefanvanburen/petstore](https://github.com/stefanvanburen/petstore).## Usage
You can interact with the API with plain HTTP requests (via the [Connect protocol](https://connectrpc.com/docs/protocol/)) with any HTTP client, such as cURL, but
[`buf curl`](https://buf.build/docs/curl/usage/) makes it easy:```console
$ # Create a pet
$ buf curl \
--data '{"name": "Mobin", "petType": "PET_TYPE_CAT"}' \
https://petstore.fly.dev/pet.v1.PetStoreService/PutPet | jq .pet.petId
"01GT4XTKXEXY74QD8H575E8NWC"$ # Retrieve a pet
$ buf curl \
--data '{"petId":"01GT4XTKXEXY74QD8H575E8NWC"}' \
https://petstore.fly.dev/pet.v1.PetStoreService/GetPet | jq .pet.name
"Mobin"$ # Delete a pet. :(
$ buf curl \
--data '{"petId":"01GT4XTKXEXY74QD8H575E8NWC"}' \
https://petstore.fly.dev/pet.v1.PetStoreService/DeletePet
{}
```You can also use [Buf Studio](https://buf.build/studio/acme/petapis/pet.v1.PetStoreService/PutPet?target=https%3A%2F%2Fpetstore.fly.dev) to interact with the API in a much more interactive way.
## Implementation details
The server uses the [connect-go library](https://github.com/connectrpc/connect-go) to implement the API, with [connectrpc/grpcreflect-go](https://github.com/connectrpc/grpcreflect-go) adding support for the gRPC server reflection API.
The packages used for interacting with the API are [remotely generated](https://buf.build/docs/bsr/generated-sdks/go) - there's no code generation in this repository.
The "database" is completely in memory, so each deploy will wipe out any existing data.