Sha256: e0c483441b10639e557805b387ab0ddd5c117397936b99d9bf3571c7c67bc996

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

Satz
====

Framework for JSON microservices

Description
-----------

Satz is a framework for writing microservices that serve and read
JSON. It uses [Syro][syro] for routing requests. Check the [Syro
tutorial][tutorial] to learn more about how the routing works.

[syro]: http://soveran.github.io/syro/
[tutorial]: http://files.soveran.com/syro/

Usage
-----

An example of a Satz application would look like this:

```ruby
App = Satz.new do
  on "players" do
    on :player_id do
      get do
        @player = Player[inbox[:player_id]]

        reply @player
      end
    end

    get do
      reply Player.all.to_a
    end

    post do
      @player = Player.new(read)

      on @player.valid? do
        @player.create

        reply @player
      end

      default do
        reply @player.errors
      end
    end
  end
end
```

The argument to `reply` is served as JSON by calling `JSON.dump(arg)`.
In user defined objects, you can define the method `to_json` according
to your needs. Most ORMs already provide meaningful definitions for
that method.

API
---

Apart from [Syro][syro]'s API, the following methods are available:

`read`: Reads the body of the requst and parses it as JSON.

`reply`: Writes to the response its argument encoded as JSON.

```
$ gem install satz
```

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
satz-0.0.1 README.md