# REST Gateway

REST API Gateway service, generated from the Swagger doc found in the root `./swagger.yml`.

The swagger doc generates Go code. We're using `https://github.com/go-swagger/go-swagger`.

Each REST endpoint calls another service internally. These are mostly gRPC calls, but there are some REST call as well.

## Updating the Swagger doc

```bash
$ swagger generate server -A MediaMagic -f ./swagger.yml
```

New endpoints added, need to be added in `./restapi/configure_media_magic.go`. There you need to add the code that backs up each endpoint. For example calling the right internal service, mapping the data to match the generated schema.

## Running this service

### Docker

```bash
$ docker build -t rest-gateway .
$ docker run -p 8080:8080 -e PORT=8080 rest-gateway
```

### Go

```bash
$ PORT=8080 go run ./cmd/media-magic-server/main.go
```

For local testing (no https)

```bash
$ go run cmd/media-magic-server/main.go --scheme http
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mediamagic.dev/product-docs/services/rest-gateway-service.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
