Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.
/ salt Public archive

**Unmaintained** A Human Friendly Interface for HTTP server written in Crystal.

License

Notifications You must be signed in to change notification settings

icyleaf/salt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • ShowExceptions
  • CommonLogger
  • Logger
  • Runtime
  • Session (Cookie/Redis)
  • Head
  • File
  • Directory
  • Static
  • SendFile
  • ETag
  • BasicAuth
  • 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.

How to Contribute

Your contributions are always welcome! Please submit a pull request or create an issue to add a new question, bug or feature to the list.

All Contributors are on the wall.

You may also like

  • halite - HTTP Requests Client with a chainable REST API, built-in sessions and loggers.
  • totem - Load and parse a configuration file or string in JSON, YAML, dotenv formats.
  • markd - Yet another markdown parser built for speed, Compliant to CommonMark specification.
  • poncho - A .env parser/loader improved for performance.
  • popcorn - Easy and Safe casting from one type to another.
  • fast-crystal - 💨 Writing Fast Crystal 😍 -- Collect Common Crystal idioms.

Resouces

Heavily inspired from Ruby's rack gem.

License

MIT License © icyleaf

About

**Unmaintained** A Human Friendly Interface for HTTP server written in Crystal.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published