Rack::SL
Rack::SL adds basic recognition of Second Life® (LSL script) requests. It parses X-SecondLife headers into structs for easy reference within Rack applications.
Install
Add the gem to your Gemfile:
gem 'rack-sl'
Accessing Parsed Information
Rack::SL adds value to Rack's env
Hash with the key sl
. This value is an OpenStruct with the following data:
Key | Value | Description | Present |
---|---|---|---|
from_sl | bool | Whether the request had all of SL's X headers | Always |
error | exception | Exception caught while parsing headers | If encountered |
name | string | Originating object's name | If from_sl |
key | string | UUID of originating object | If from_sl |
region | struct | Struct with region name and x and y coordinates |
If from_sl |
owner | struct | Struct with owner's name and key (UUID) |
If from_sl |
position | struct | Struct with x , y and z coordinates |
If from_sl |
rotation | struct | Struct with x , y , z and s coordinates |
If from_sl |
velocity | struct | Struct with x , y and z coordinates |
If from_sl |
Rails
Configure Rails to use Rack::SL in the config/application.rb
file:
module MyApp
class Application < Rails::Application
# ...
config.middleware.use Rack::SL
end
end
Sinatra
require 'sinatra'
configure do
use Rack::SL
end
# ...
...or in a modular app:
require 'sinatra/base'
class MyApp < Sinatra::Base
configure do
# ...
use Rack::SL
end
# ...
run!
end