salt

A Human Friendly Interface for HTTP server webserver webserver-interface
0.4.2 released
icyleaf/salt
19 2
icyleaf

Archived shard

This shard has been archived . It is no longer maintained or has been discontinued for other reasons.

salt icon

A Human Friendly Interface for HTTP webservers written in Crystal.

Project Status Langugea License

"Salt" icon by Creative Stall from Noun Project.

Installation

Add this to your application's shard.yml:

dependencies:
  salt:
    github: icyleaf/salt
    branch: master

Usage

require "salt"
require "salt/middlewares/session/cookie"
require "salt/middlewares/logger"

class Talk < Salt::App
  def call(env)
    env.session.set("username", "icyleaf")
    env.logger.info("Start Talking!")
    {400, { "Content-Type" => "text/plain" }, ["Can I talk to salt?"]}
  end
end

class Shout < Salt::App
  def call(env)
    call_app(env)

    env.logger.debug("Shout class")
    {status_code, headers, body.map &.upcase }
  end
end

class Speaking < Salt::App
  def call(env)
    call_app(env)

    env.logger.debug("Speaking class")
    {200, headers, ["This is Slat speaking! #{env.session.get("username")}"]}
  end
end

Salt.use Salt::Session::Cookie, secret: "<change me>"
Salt.use Salt::Logger, level: Logger::DEBUG, progname: "app"
Salt.use Shout
Salt.use Speaking

Salt.run Talk.new

Available middleware

  • [x] ShowExceptions
  • [x] CommonLogger
  • [x] Logger
  • [x] Runtime
  • [x] Session (Cookie/Redis)
  • [x] Head
  • [x] File
  • [x] Directory
  • [x] Static
  • [ ] SendFile
  • [x] ETag
  • [x] BasicAuth
  • [x] Router (lightweight)

All these components use the same interface, which is described in detail in the Salt::App specification. These optional components can be used in any way you wish.

Contributing

  1. Fork it ( https://github.com/icyleaf/salt/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Resouces

Heavily inspired from Ruby's rack gem.

salt:
  github: icyleaf/salt
  version: ~> 0.4.2
License MIT
Crystal 0.25.1

Authors

Dependencies 1

  • mime~icyleaf ~> 0.1.0
    {'github' => 'icyleaf/mime.cr', 'version' => '~> 0.1.0'}

Development Dependencies 2

  • radix ~> 0.3.8
    {'github' => 'luislavena/radix', 'version' => '~> 0.3.8'}
  • redis ~> 1.11.0
    {'github' => 'stefanwille/crystal-redis', 'version' => '~> 1.11.0'}

Dependents 0

Last synced .
search fire star recently