A Go-based API server for interacting with Rewst workflows, converted from Node.js.
Requires Go 1.20 or newer.
rewst-api-server/
├── cmd/
│ └── server/
│ └── main.go # Application entry point
├── internal/
│ ├── handlers/
│ │ └── handlers.go # HTTP request handlers
│ ├── middleware/
│ │ └── middleware.go # HTTP middleware (logging, CORS)
│ └── rewst/
│ └── client.go # Rewst API client
├── go.mod # Go module definition
├── go.sum # Go module checksums
├── Dockerfile # Docker container definition
├── docker-compose.yml # Docker Compose configuration
└── README.md # This file
- Workflow Execution: Run Rewst workflows with custom parameters
- Status Monitoring: Check the status of running workflows
- Health Checks: Built-in health check endpoint
- Middleware: Request logging and CORS support
- Containerization: Docker and Docker Compose support
- Environment Configuration: Environment variable support with .env files
POST /api/workflows/{id}/run
Request body:
{
"parameters": {
"key1": "value1",
"key2": "value2"
},
"context": {
"user_id": "123",
"organization": "example"
}
}GET /api/workflows/{id}/status
GET /api/health
Create a .env file in the root directory:
REWST_API_KEY=your_rewst_api_key_here
PORT=3000Required:
REWST_API_KEY: Your Rewst API key
Optional:
PORT: Server port (defaults to 3000)
-
Clone the repository
git clone <repository-url> cd rewst-api-server
-
Install dependencies
go mod download
-
Set up environment variables
cp .env.example .env # Edit .env with your Rewst API key -
Run the server
go run cmd/server/main.go
-
Build and run with Docker Compose
docker-compose up --build
-
Or build and run manually
docker build -t rewst-api-server . docker run -p 3000:3000 --env-file .env rewst-api-server
This project follows the standard Go project layout:
cmd/: Main applications for this projectinternal/: Private application and library codeinternal/handlers/: HTTP request handlersinternal/middleware/: HTTP middleware componentsinternal/rewst/: Rewst API client implementation
# Build for current platform
go build -o server ./cmd/server
# Build for Linux (useful for Docker)
CGO_ENABLED=0 GOOS=linux go build -o server ./cmd/server# Run tests
go test ./...
# Run tests with coverage
go test -cover ./...curl -X POST http://localhost:3000/api/workflows/your-workflow-id/run \
-H "Content-Type: application/json" \
-d '{
"parameters": {
"input_param": "test_value"
},
"context": {
"user_id": "123"
}
}'curl http://localhost:3000/api/workflows/your-workflow-id/statuscurl http://localhost:3000/api/healthThe server can be configured using environment variables:
| Variable | Description | Default |
|---|---|---|
REWST_API_KEY |
Rewst API authentication key | Required |
PORT |
Server port | 3000 |
The API returns appropriate HTTP status codes:
200: Success400: Bad Request (invalid JSON, missing parameters)500: Internal Server Error (API errors, network issues)
Error responses include descriptive messages in the response body.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
[Add your license information here]