2022-04-11 09:35:06 +00:00
|
|
|
<p align="center">
|
2022-12-16 09:45:15 +00:00
|
|
|
<img src="./.github/logo.svg" width="500px" alt="FrostFS">
|
2022-04-11 09:35:06 +00:00
|
|
|
</p>
|
|
|
|
<p align="center">
|
2022-12-16 09:45:15 +00:00
|
|
|
REST server to interact with <a href="https://frostfs.info">FrostFS</a>.
|
2022-04-11 09:35:06 +00:00
|
|
|
</p>
|
|
|
|
|
|
|
|
---
|
2022-12-16 09:45:15 +00:00
|
|
|
[![Report](https://goreportcard.com/badge/github.com/TrueCloudLab/frostfs-rest-gw)](https://goreportcard.com/report/github.com/TrueCloudLab/frostfs-rest-gw)
|
|
|
|
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/TrueCloudLab/frostfs-rest-gw?sort=semver)
|
|
|
|
![License](https://img.shields.io/github/license/TrueCloudLab/frostfs-rest-gw.svg?style=popout)
|
2022-04-11 09:35:06 +00:00
|
|
|
|
2022-12-16 09:45:15 +00:00
|
|
|
# frostfs-rest-gw
|
2022-04-11 09:35:06 +00:00
|
|
|
|
2022-12-16 09:45:15 +00:00
|
|
|
FrostFS REST Gateway bridges FrostFS internal protocol and REST API server.
|
2022-04-11 09:35:06 +00:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
### Building
|
|
|
|
|
|
|
|
Before building make sure you have the following tools:
|
|
|
|
|
|
|
|
* go
|
|
|
|
* make
|
|
|
|
* git
|
|
|
|
* curl
|
2022-08-12 09:17:46 +00:00
|
|
|
* docker
|
2022-04-11 09:35:06 +00:00
|
|
|
|
2022-08-12 09:17:46 +00:00
|
|
|
First clone this repository:
|
|
|
|
|
|
|
|
```shell
|
2022-12-16 09:45:15 +00:00
|
|
|
$ git clone https://github.com/TrueCloudLab/frostfs-rest-gw
|
2022-08-12 09:17:46 +00:00
|
|
|
```
|
|
|
|
|
2022-12-16 09:45:15 +00:00
|
|
|
Then run make to build `bin/frostfs-rest-gw` binary:
|
2022-08-12 09:17:46 +00:00
|
|
|
|
|
|
|
```shell
|
|
|
|
$ make
|
|
|
|
```
|
|
|
|
|
|
|
|
Or you can build it using docker:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
$ make docker/all
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Generate go-swagger boilerplate code
|
|
|
|
|
|
|
|
If you change the [spec file](./spec/rest.yaml) you have to re-generate go-swagger server code.
|
|
|
|
|
|
|
|
You have several approaches:
|
|
|
|
|
|
|
|
1. Run make. It automatically downloads `swagger` and generates boilerplate.
|
|
|
|
|
|
|
|
```shell
|
|
|
|
$ make
|
|
|
|
```
|
|
|
|
|
|
|
|
2. Generate code separately:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
$ make generate-server
|
|
|
|
```
|
|
|
|
|
|
|
|
Or using docker:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
$ make docker/generate-server
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Other targets
|
2022-04-11 09:35:06 +00:00
|
|
|
|
|
|
|
Notable make targets:
|
|
|
|
|
|
|
|
```
|
|
|
|
dep Check and ensure dependencies
|
|
|
|
image Build clean docker image
|
|
|
|
image-dirty Build dirty docker image with host-built binaries
|
|
|
|
formats Run all code formatters
|
|
|
|
lint Run linters
|
|
|
|
version Show current version
|
|
|
|
generate-server Generate boilerplate by spec
|
|
|
|
```
|
|
|
|
|
|
|
|
### Docker
|
|
|
|
|
2022-12-16 12:41:49 +00:00
|
|
|
Or you can also use a [Docker image](https://hub.docker.com/r/truecloudlab/frostfs-rest-gw) provided for released
|
2022-04-11 09:35:06 +00:00
|
|
|
(and occasionally unreleased) versions of gateway (`:latest` points to the latest stable release).
|
|
|
|
|
|
|
|
## Execution
|
|
|
|
|
2022-12-16 09:45:15 +00:00
|
|
|
REST gateway itself is not a FrostFS node, so to access FrostFS it uses node's gRPC interface and you need to provide some
|
2022-10-13 06:41:57 +00:00
|
|
|
node that it will connect to. This can be done either via `-p` parameter or via `REST_GW_POOL_PEERS_<N>_ADDRESS` and
|
2022-12-16 09:45:15 +00:00
|
|
|
`REST_GW_POOL_PEERS_<N>_WEIGHT` environment variables (the gate supports multiple FrostFS nodes with weighted load balancing).
|
2022-04-11 09:35:06 +00:00
|
|
|
|
2022-12-16 09:45:15 +00:00
|
|
|
If you're launching REST gateway in bundle with [frostfs-dev-env](https://github.com/TrueCloudLab/frostfs-dev-env), you can get
|
2022-04-11 09:35:06 +00:00
|
|
|
an IP address of the node in output of `make hosts` command
|
|
|
|
(with s0*.neofs.devenv name).
|
|
|
|
|
|
|
|
These two commands are functionally equivalent, they run the gate with one backend node (and otherwise default
|
|
|
|
settings):
|
|
|
|
|
2022-08-11 14:57:54 +00:00
|
|
|
```shell
|
2022-12-16 09:45:15 +00:00
|
|
|
$ frostfs-rest-gw -p 192.168.130.72:8080
|
|
|
|
$ REST_GW_POOL_PEERS_0_ADDRESS=192.168.130.72:8080 frostfs-rest-gw
|
2022-04-11 09:35:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
It's also possible to specify uri scheme (grpc or grpcs) when using `-p`:
|
|
|
|
|
2022-08-11 14:57:54 +00:00
|
|
|
```shell
|
2022-12-16 09:45:15 +00:00
|
|
|
$ frostfs-rest-gw -p grpc://192.168.130.72:8080
|
|
|
|
$ REST_GW_POOL_PEERS_0_ADDRESS=grpcs://192.168.130.72:8080 frostfs-rest-gw
|
2022-04-11 09:35:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
In general, everything available as CLI parameter can also be specified via environment variables, so they're not
|
2022-08-11 14:57:54 +00:00
|
|
|
specifically mentioned in most cases (see `--help` also). If you prefer a config file you can use it in yaml format.
|
|
|
|
See [config](./config/config.yaml) and [defaults](./docs/gate-configuration.md) for example.
|
|
|
|
|
|
|
|
```shell
|
2022-12-16 09:45:15 +00:00
|
|
|
$ frostfs-rest-gw --config config.yaml
|
2022-08-11 14:57:54 +00:00
|
|
|
```
|
2022-07-12 07:31:06 +00:00
|
|
|
|
|
|
|
## Docs
|
2022-08-11 14:57:54 +00:00
|
|
|
|
|
|
|
You can see additional docs and swagger specification using the following url
|
|
|
|
(suppose you ran rest-gw on `localhost:8090`):
|
|
|
|
|
2022-07-12 07:31:06 +00:00
|
|
|
* http://localhost:8090/docs - rest-gw documentation
|
|
|
|
* http://localhost:8090/v1/docs - swagger specification
|
2022-08-11 12:24:04 +00:00
|
|
|
|
|
|
|
## Contributing
|
|
|
|
|
2022-08-11 14:57:54 +00:00
|
|
|
Feel free to contribute to this project after reading the [contributing guidelines](CONTRIBUTING.md).
|
2022-08-11 12:24:04 +00:00
|
|
|
|
|
|
|
Before starting to work on a certain topic, create a new issue first, describing
|
|
|
|
the feature/topic you are going to implement.
|
2022-08-15 06:49:05 +00:00
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
This project is licensed under the GNU GPL v3 License -
|
|
|
|
see the [LICENSE](LICENSE) file for details.
|