Skip to content

Commit

Permalink
resolve review
Browse files Browse the repository at this point in the history
  • Loading branch information
brngylni committed Jul 9, 2024
1 parent f81f697 commit 7ac2d20
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions webhook_to_fedora_messaging/endpoints/util.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
from flask import Response, Request


def not_found() -> Response:
return Response({'message': 'Not Found'}, status=404, mimetype='application/json')


def success(data: dict) ->Response:
return Response(data, status=200, mimetype='application/json')


def bad_request() -> Response:
return Response("{'message': 'Bad Request'}", status=400, mimetype='application/json')


def created(data: dict) -> Response:
return Response(data, status=201, mimetype='application/json')


def conflict(data: dict) -> Response:
return Response(data, status=409, mimetype='application/json')

def validate_request(request: Request, fields=['username']):
return all(field in request for field in fields)

def unprocessable_entity() -> Response:
return Response("{'message: 'Unprocessable Entity'}", status=429, mimetype="application/json")


def validate_request(request: dict, fields=['username']) -> bool:
return all(field in request for field in fields)

0 comments on commit 7ac2d20

Please sign in to comment.