Skip to content

Commit

Permalink
automatically convert Hash success bodies to JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalextremist committed Dec 16, 2019
1 parent 47f752d commit 4abf267
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v201912160309-6Mg3 0.0.1.31
* Allow passing Hash to Artillery::Shot#success which automatically converts to JSON

# v201912160106-6Mg3 0.0.1.30
* Revamped Artillery::Shell::Request, especially Payload type and handling
* Setup proper target for artillery-mountpoint to begin using out of bazooka mode
Expand Down
3 changes: 2 additions & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: artillery
version: 0.0.1.30
version: 0.0.1.31

description: Serverfree object-oriented microservice architecture.

Expand All @@ -11,6 +11,7 @@ crystal: 0.31.1
executables:
- artillery
- bazooka
- artillery-mountpoint

license: MIT

Expand Down
15 changes: 15 additions & 0 deletions src/artillery/shot.cr
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ module Artillery
@response.body = body unless body.nil?
end

alias ResponseHash = Hash(String, Char |
String |
Bool |
Float64 |
Int64 |
Int32 |
Int16 |
Array(ResponseHash) |
Hash(String, ResponseHash))

def success(body : ResponseHash)
@response.status = 200
@response.body = body.to_json
end

def redirect(@redirect)
end

Expand Down

0 comments on commit 4abf267

Please sign in to comment.