Sha256: b7e71a04dabada7e0ca5c325bbb30eae66ed57bb445cfa46d8bdfb4131995848

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

# thin start -R http_router -p 3000
#
# http://localhost:3000/media/170x240+210+210/m/pic1.jpg
# http://localhost:3000/media/170x240/m/pic1.jpg
# http://localhost:3000/media/100x100-ne/m/pic1.jpg
# http://localhost:3000/media/100x100-c/m/pic1.jpg
# http://localhost:3000/media/100x100-c/greyscale/pic1.jpg

require 'rubygems'
# require 'bundler'
# Bundler.setup

require 'http_router'

$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'anisoptera'

Anisoptera[:media].configure do |config|
  config.base_path = './'
end

# Anisoptera.prefer_async = false # uncomment this to test synchronous endpoint with any Rack server


routes = HttpRouter.new do
  
  add('/media/:geometry/:color_mode/:filename').to Anisoptera[:media].endpoint {|image, params|
    image.file(params[:filename]).thumb(params[:geometry])
    image.greyscale if params[:color_mode] == 'grey'
    image.encode('png')
  }
  
end

run routes

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
anisoptera-0.0.2 examples/http_router.ru