Skip to content

Commit

Permalink
Merge 6533b14 into d4353f0
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-gre authored Jul 10, 2020
2 parents d4353f0 + 6533b14 commit 4b481bd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions prometheus_flask_exporter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import dataclasses
import os
import re
import sys
Expand Down Expand Up @@ -624,6 +625,15 @@ def func(*args, **kwargs):
except AttributeError:
break

# Breaks dataclass/list of dataclass down to dict/dicts.
if dataclasses.is_dataclass(response):
response = dataclasses.asdict(response[0]), 200
if isinstance(response, tuple):
if dataclasses.is_dataclass(response[0]):
response = dataclasses.asdict(response[0]), response[1]
elif isinstance(response[0], list) and dataclasses.is_dataclass(response[0][0]):
response = [dataclasses.asdict(x) for x in response[0]], response[1]

if view_func == f:
# we are in a request handler method
response = make_response(response)
Expand Down

0 comments on commit 4b481bd

Please sign in to comment.