Skip to content

minimally process standard lambda (dict) responses#59

Merged
sloev merged 10 commits intosloev:masterfrom
adamdotdevin:adamelmore/dict-responses
Feb 14, 2020
Merged

minimally process standard lambda (dict) responses#59
sloev merged 10 commits intosloev:masterfrom
adamdotdevin:adamelmore/dict-responses

Conversation

@adamdotdevin
Copy link
Copy Markdown
Contributor

Personally, I'd prefer to be able to return a normal lambda response from my handlers and not have to introduce a library-specific output format:

@lambda_handler.handle("get", path="/")
def index(event: dict) -> dict:
	return {
		"statusCode": 302,
		"headers": {
			"Location": "https://example.com"
		}
	}

This allows the library to be used solely for its routing capabilities which is desirable to those that aren't interested in any output massaging.

@sloev
Copy link
Copy Markdown
Owner

sloev commented Feb 13, 2020

i am looking into it, i am using the opportunity to overhaul the travis versions test setup as well. stay tuned

@sloev
Copy link
Copy Markdown
Owner

sloev commented Feb 13, 2020

The travis tests are failing because of some linting plus python3.5 not being able to sort dicts during json dumping (i think) i have fixed both issues in a local copy of your branch. I will push them tomorrow when i get time.
Thx for contributing good aditions!

If you dont mind, i'd really like to hear more about how you stumbled upon lambdarest and what you generally use it for and in what scale (just for curiosity)

@adamdotdevin
Copy link
Copy Markdown
Contributor Author

I found this library because I'm a huge fan of the AWS CDK and I wanted a lightweight library that could help with routing without all of the deploy/infra baggage that comes with Chalice/Zappa/etc.

I was going to roll my own as my first Google results weren't promising. I finally dug this repo up in Google with the right incantation after a few tries 😅.

I'm using it for pet projects at the moment, but, ultimately I'm vetting it for my day job—we build everything in python on AWS.

@sloev sloev force-pushed the adamelmore/dict-responses branch 11 times, most recently from 3ef023c to 73d39e9 Compare February 14, 2020 19:22
@sloev
Copy link
Copy Markdown
Owner

sloev commented Feb 14, 2020

@adamelmore
i've added your changes including the sort_keys=True

but i've removed the explicit assertion (in the test) that keys are indeed ordered after json encoding as its not part of the JSON rfc:

An object is an unordered collection of zero or more name/value
pairs, where a name is a string and a value is a string, number,
boolean, null, object, or array.

else i have revamped the setup/test instructions and switched back to using tox + pyenv for easy local testing against all major supported python versions

btw. i have bumped the version to v8.0.0 as this seems like a breaking change as well as the last one

edit: i am gonna merge this now

@sloev sloev force-pushed the adamelmore/dict-responses branch 3 times, most recently from 5de5fbd to a7d6b53 Compare February 14, 2020 19:40
@sloev sloev force-pushed the adamelmore/dict-responses branch from a7d6b53 to 34ad7bd Compare February 14, 2020 19:43
@sloev sloev merged commit 51c15db into sloev:master Feb 14, 2020
@sloev
Copy link
Copy Markdown
Owner

sloev commented Feb 14, 2020

@adamelmore its released under v8.0.0 and tested installed:

pip install lambdarest
Collecting lambdarest
  Downloading lambdarest-8.0.0.tar.gz (13 kB)
Requirement already satisfied: jsonschema>=3.2.0 in /site-packages (from lambdarest) (3.2.0)
Requirement already satisfied: strict_rfc3339>=0.7 in /site-packages (from lambdarest) (0.7)
Requirement already satisfied: werkzeug>=0.16.1 in /site-packages (from lambdarest) (1.0.0)
Requirement already satisfied: attrs>=17.4.0 in /site-packages (from jsonschema>=3.2.0->lambdarest) (19.3.0)
Requirement already satisfied: importlib-metadata; python_version < "3.8" in /site-packages (from jsonschema>=3.2.0->lambdarest) (1.5.0)
Requirement already satisfied: setuptools in /site-packages (from jsonschema>=3.2.0->lambdarest) (41.2.0)
Requirement already satisfied: six>=1.11.0 in /site-packages (from jsonschema>=3.2.0->lambdarest) (1.14.0)
Requirement already satisfied: pyrsistent>=0.14.0 in /site-packages (from jsonschema>=3.2.0->lambdarest) (0.15.7)
Requirement already satisfied: zipp>=0.5 in /site-packages (from importlib-metadata; python_version < "3.8"->jsonschema>=3.2.0->lambdarest) (2.2.0)
Installing collected packages: lambdarest
    Running setup.py install for lambdarest ... done
Successfully installed lambdarest-8.0.0

@sloev
Copy link
Copy Markdown
Owner

sloev commented Feb 14, 2020

LOL after squashing and merging it looks like you accomplished quite a lot more! 🤣

Screenshot 2020-02-14 at 20 58 56

@adamdotdevin adamdotdevin deleted the adamelmore/dict-responses branch February 15, 2020 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants