Sha256: a660dce8e0a0dc44b1732555e483fe4c74dda0bdc154281130e92896a3e04072
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
require 'forwardable' require 'sinatra/base' require 'slim' require_relative 'project' require_relative 'repos' require_relative 'task_dispatcher' require_relative 'uuid' module Kamerling class HTTPAPI < Sinatra::Base extend Forwardable delegate %i(task_dispatcher repos) => :settings configure { set task_dispatcher: TaskDispatcher.new, repos: Repos } get '/' do render_template :root end get '/clients' do render_template :clients, locals: { clients: repos.clients } end get '/projects' do render_template :projects, locals: { projects: repos.projects } end get '/projects/:project_uuid' do project = repos.project(params['project_uuid']) clients = repos.clients_for(project) tasks = repos.tasks_for(project) render_template :project, locals: { clients: clients, tasks: tasks } end post '/projects' do name = params.fetch('name') uuid = params.fetch('uuid') repos << Project.new(name: name, uuid: uuid) redirect '/projects' end post '/projects/dispatch' do task_dispatcher.dispatch_all redirect '/projects' end private def render_template(template, locals: {}) warn_off { slim template, locals: locals } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kamerling-0.0.3 | lib/kamerling/http_api.rb |