Commit 634cbd71 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Refactor API classes. So api classes like Gitlab::Issues become API::Issues

parent 94991cc49cf2
......@@ -152,7 +152,7 @@ def default_headers
def add_gon_variables
gon.default_issues_tracker = Project.issues_tracker.default_value
gon.api_version = Gitlab::API.version
gon.api_version = API::API.version
gon.api_token = current_user.private_token if current_user
gon.gravatar_url = request.ssl? ? Gitlab.config.gravatar.ssl_url : Gitlab.config.gravatar.plain_url
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
......
require 'sidekiq/web'
require 'api/api'
Gitlab::Application.routes.draw do
#
......@@ -7,9 +8,8 @@
get 'search' => "search#show"
# API
require 'api'
Gitlab::API.logger Rails.logger
mount Gitlab::API => '/api'
API::API.logger Rails.logger
mount API::API => '/api'
constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? }
constraints constraint do
......
Dir["#{Rails.root}/lib/api/*.rb"].each {|file| require file}
module Gitlab
module API
class API < Grape::API
version 'v3', using: :path
......
module Gitlab
module API
module Entities
class User < Grape::Entity
expose :id, :username, :email, :name, :bio, :skype, :linkedin, :twitter,
......
module Gitlab
module API
# groups API
class Groups < Grape::API
before { authenticate! }
......
module Gitlab
module API
module APIHelpers
def current_user
@current_user ||= User.find_by_authentication_token(params[:private_token] || env["HTTP_PRIVATE_TOKEN"])
......
module Gitlab
module API
# Internal access API
class Internal < Grape::API
namespace 'internal' do
......@@ -58,7 +58,7 @@ class Internal < Grape::API
get "/check" do
{
api_version: Gitlab::API.version,
api_version: API.version,
gitlab_version: Gitlab::VERSION,
gitlab_rev: Gitlab::REVISION,
}
......
module Gitlab
module API
# Issues API
class Issues < Grape::API
before { authenticate! }
......
module Gitlab
module API
# MergeRequest API
class MergeRequests < Grape::API
before { authenticate! }
......
module Gitlab
module API
# Milestones API
class Milestones < Grape::API
before { authenticate! }
......
module Gitlab
module API
# Notes API
class Notes < Grape::API
before { authenticate! }
......
module Gitlab
module API
# Projects API
class Projects < Grape::API
before { authenticate! }
......
module Gitlab
module API
# Users API
class Session < Grape::API
# Login to get token
......
module Gitlab
module API
# Hooks API
class SystemHooks < Grape::API
before {
......
module Gitlab
module API
# Users API
class Users < Grape::API
before { authenticate! }
......
require 'spec_helper'
describe Gitlab::API do
describe API::API do
include ApiHelpers
let(:user1) { create(:user) }
......
require 'spec_helper'
describe Gitlab::API do
describe API::API do
include ApiHelpers
let(:user) { create(:user) }
......@@ -12,7 +12,7 @@
get api("/internal/check")
response.status.should == 200
json_response['api_version'].should == Gitlab::API.version
json_response['api_version'].should == API::API.version
end
end
......
require 'spec_helper'
describe Gitlab::API do
describe API::API do
include ApiHelpers
let(:user) { create(:user) }
......
require "spec_helper"
describe Gitlab::API do
describe API::API do
include ApiHelpers
let(:user) { create(:user ) }
......
require 'spec_helper'
describe Gitlab::API do
describe API::API do
include ApiHelpers
before(:each) { enable_observers }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment