add Rack::PostBodyContentTypeParser and fix locale update
This commit is contained in:
parent
f09cb3cac0
commit
6dc28f0c49
1
Gemfile
1
Gemfile
|
@ -7,6 +7,7 @@ gem 'travis-support', github: 'travis-ci/travis-support'
|
||||||
gem 'travis-core', github: 'travis-ci/travis-core', branch: 'sf-more-services'
|
gem 'travis-core', github: 'travis-ci/travis-core', branch: 'sf-more-services'
|
||||||
gem 'hubble', github: 'roidrage/hubble'
|
gem 'hubble', github: 'roidrage/hubble'
|
||||||
gem 'yard-sinatra', github: 'rkh/yard-sinatra'
|
gem 'yard-sinatra', github: 'rkh/yard-sinatra'
|
||||||
|
gem 'rack-contrib', github: 'rack/rack-contrib'
|
||||||
gem 'gh', github: 'rkh/gh'
|
gem 'gh', github: 'rkh/gh'
|
||||||
gem 'bunny'
|
gem 'bunny'
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ class Travis::Api::App
|
||||||
use Hubble::Rescuer, env: Travis.env, codename: ENV['CODENAME'] if Endpoint.production? && ENV['HUBBLE_ENDPOINT']
|
use Hubble::Rescuer, env: Travis.env, codename: ENV['CODENAME'] if Endpoint.production? && ENV['HUBBLE_ENDPOINT']
|
||||||
use Rack::Protection::PathTraversal
|
use Rack::Protection::PathTraversal
|
||||||
use Rack::SSL if Endpoint.production?
|
use Rack::SSL if Endpoint.production?
|
||||||
|
use Rack::PostBodyContentTypeParser
|
||||||
use Rack::JSONP
|
use Rack::JSONP
|
||||||
use ActiveRecord::ConnectionAdapters::ConnectionManagement
|
use ActiveRecord::ConnectionAdapters::ConnectionManagement
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Travis::Api::App
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Add implementation and documentation.
|
# TODO: Add implementation and documentation.
|
||||||
put('/:id', scope: :admin) do
|
put('/:id', scope: :private) do
|
||||||
body service(:hooks).update(params)
|
body service(:hooks).update(params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,8 @@ require 'travis/api/app'
|
||||||
class Travis::Api::App
|
class Travis::Api::App
|
||||||
class Endpoint
|
class Endpoint
|
||||||
class Profile < Endpoint
|
class Profile < Endpoint
|
||||||
|
LOCALES = %w(en es fr ja eb nl pl pt-Br ru) # TODO how to figure these out
|
||||||
|
|
||||||
# Gives information about the currently logged in user.
|
# Gives information about the currently logged in user.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -23,7 +25,7 @@ class Travis::Api::App
|
||||||
end
|
end
|
||||||
|
|
||||||
put '/', scope: :private do
|
put '/', scope: :private do
|
||||||
raise NotImplementedError
|
p params
|
||||||
update_locale if valid_locale?
|
update_locale if valid_locale?
|
||||||
'ok'
|
'ok'
|
||||||
end
|
end
|
||||||
|
@ -45,17 +47,18 @@ class Travis::Api::App
|
||||||
end
|
end
|
||||||
|
|
||||||
def locale
|
def locale
|
||||||
params[:user][:locale]
|
params[:profile][:locale].to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_locale?
|
def valid_locale?
|
||||||
I18n.available_locales.include?(locale.to_sym) # ???
|
LOCALES.include?(locale)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_locale
|
def update_locale
|
||||||
current_user.update_attributes!(:locale => locale.to_s)
|
current_user.update_attribute(:locale, locale.to_s)
|
||||||
session[:locale] = locale # ???
|
# session[:locale] = locale # ???
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Travis::Api::App
|
||||||
# Logging is set up by custom middleware
|
# Logging is set up by custom middleware
|
||||||
disable :protection, :logging, :setup
|
disable :protection, :logging, :setup
|
||||||
enable :raise_errors
|
enable :raise_errors
|
||||||
disable :dump_errors
|
# disable :dump_errors
|
||||||
register :subclass_tracker
|
register :subclass_tracker
|
||||||
helpers :json_renderer
|
helpers :json_renderer
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user