Skip to content

Commit

Permalink
[mini-relay] collect data (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile-sentry authored Nov 28, 2023
1 parent 9d29e37 commit 39f597b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ services:
build: mini-relay
init: true
ports: [9989:9989]
volumes: [./mini-relay/data:/data:rw]
postgres:
image: 'postgres:alpine'
environment:
Expand Down
14 changes: 13 additions & 1 deletion mini-relay/app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
from __future__ import annotations

import os
import gzip
import time

import flask

app = flask.Flask(__name__)


@app.post('/api/<p>/envelope/')
def envelope(p: str) -> flask.Response:
# TODO: save out flask.request.data
if flask.request.headers.get('content-encoding', 'identity') == 'gzip':
data = gzip.decompress(flask.request.data)
else:
data = flask.request.data

os.makedirs(f'/data/{p}', exist_ok=True)
with open(f'/data/{p}/{time.monotonic()}', 'wb') as f:
f.write(data)

ret = app.make_response(('', 204))
ret.access_control_allow_origin = '*'
return ret
Expand Down
2 changes: 2 additions & 0 deletions mini-relay/data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore

0 comments on commit 39f597b

Please sign in to comment.