defaults format: :json do 
  namespace :api do 
    namespace :v1 do 
      scope ':owner' do 
        resource :users, path: '/', only: [:show, :update, :edit, :destroy] do 
          collection do
            get :send_email_vefify_code
            post :check_password 
            post :check_email
            post :check_email_verify_code
            patch :update_email
          end
        end
        scope module: :users do 
          resources :projects, only: [:index]
          resources :feedbacks, only: [:create]
        end

        scope ':repo' do 
          # projects
          resource :projects, path: '/', only: [:show, :update, :edit, :destroy] do 
            collection do 
              get :compare
              get :blame
            end
          end

          # projects文件夹下的
          scope module: :projects do 
            resources :issues
            resources :pulls, module: 'pulls' do 
              resources :versions, only: [:index] do 
                member do 
                  get :diff
                end
              end
              resources :journals, except: [:show, :edit]
              resources :reviews, only: [:index, :create] 
            end

            resources :versions 
            resources :release_versions
            resources :webhooks do 
              member do 
                post :tests 
                get :hooktasks 
              end
            end
            resources :branches, only:[:index, :create] do 
              collection do 
                get :all 
              end
            end
            resources :commits, only: [:index]
            resources :code_stats, only: [:index]
            get '/commits/:sha/diff', to: 'commits#diff'
            get '/git/blobs/:sha', to: 'git#blobs'
            get '/git/trees/:sha', to: 'git#trees'

            resources :contents, only: [:index] do 
              collection do 
                post :batch
              end
            end
          end
        end

      end

      resources :projects, only: [:index]

      
    end
  end
end