Skip to content

πŸ“ mruby-pong is a simple library for quickly creating web applications in MRuby

License

Notifications You must be signed in to change notification settings

gdwrd/mruby-pong

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

mruby-pong πŸ“

    β–ˆβ–ˆβ–“β–ˆβ–ˆβ–ˆ   β–’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆβ–ˆβ–„    β–ˆ   β–„β–ˆβ–ˆβ–ˆβ–ˆ 
  β–“β–ˆβ–ˆβ–‘  β–ˆβ–ˆβ–’β–’β–ˆβ–ˆβ–’  β–ˆβ–ˆβ–’ β–ˆβ–ˆ β–€β–ˆ   β–ˆ  β–ˆβ–ˆβ–’ β–€β–ˆβ–’
  β–“β–ˆβ–ˆβ–‘ β–ˆβ–ˆβ–“β–’β–’β–ˆβ–ˆβ–‘  β–ˆβ–ˆβ–’β–“β–ˆβ–ˆ  β–€β–ˆ β–ˆβ–ˆβ–’β–’β–ˆβ–ˆβ–‘β–„β–„β–„β–‘
  β–’β–ˆβ–ˆβ–„β–ˆβ–“β–’ β–’β–’β–ˆβ–ˆ   β–ˆβ–ˆβ–‘β–“β–ˆβ–ˆβ–’  β–β–Œβ–ˆβ–ˆβ–’β–‘β–“β–ˆ  β–ˆβ–ˆβ–“
  β–’β–ˆβ–ˆβ–’ β–‘  β–‘β–‘ β–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘β–’β–ˆβ–ˆβ–‘   β–“β–ˆβ–ˆβ–‘β–‘β–’β–“β–ˆβ–ˆβ–ˆβ–€β–’
  β–’β–“β–’β–‘ β–‘  β–‘β–‘ β–’β–‘β–’β–‘β–’β–‘ β–‘ β–’β–‘   β–’ β–’  β–‘β–’   β–’ 
  β–‘β–’ β–‘       β–‘ β–’ β–’β–‘ β–‘ β–‘β–‘   β–‘ β–’β–‘  β–‘   β–‘ 
  β–‘β–‘       β–‘ β–‘ β–‘ β–’     β–‘   β–‘ β–‘ β–‘ β–‘   β–‘ 
                β–‘ β–‘           β–‘       β–‘ 

Build Status MRuby Version

mruby-pong it's a simple web server for building simple Sinatra-like applications

mruby-pong-example

Installation

Add line to your build_config.rb

MRuby::Build.new do |config|
  # some lines of your config
  config.gem :github => 'nsheremet/mruby-pong'
  # other lines of your config
end

Usage

Simple App:

app = Pong.new

app.get '/' do
  html '<h1>Hello from PONG</h1>'
end

app.run

Your can user custom configuration:

app = Pong.new({
    port: 8080,
    threads: 24,
    debug: true
})

Request handling examples:

app.post '/users' do |request|
  # request have a structure
  # {
  #   params: {Hash},
  #   headers: {Hash},   
  #   method: {String}, additional fields,
  #   url: {String}, additional fields
  # }
  
  params: request[:params]

  json Hash[params: params], 201, headers # Status Code and Headers are optional
end

What I need to return in action?

# HTML
html page, status_code, headers # page is string with HTML content

# JSON
json hash, status_code, headers

# Redirect
redirect_to '/' # accept only one String param

# RAW hash
# You can return what you want, just create hash with required 'Content-Type' header
{
    headers: { 'Content-Type' => 'text/xml' }, # You need to setup Content-Type headers
    status: 200,
    body: '<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don\'t foget me this weekend!</body></note>'
}

License

mruby-pong is primarily distributed under the terms of Mozilla Public License 2.0.

See LICENSE for details.

About

πŸ“ mruby-pong is a simple library for quickly creating web applications in MRuby

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published