Skip to content

Commit

Permalink
Merge pull request #26 from unipept/fix/options_request_api
Browse files Browse the repository at this point in the history
Properly handle options request for /api endpoints
  • Loading branch information
pverscha authored Sep 15, 2023
2 parents c155583 + ab8a043 commit 3c038ab
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/api_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'octokit'

class Api::ApiController < ApplicationController
class Api::ApiController < HandleOptionsController
respond_to :json

before_action :set_headers, only: %i[pept2taxa pept2lca pept2prot pept2funct pept2ec pept2go pept2interpro peptinfo taxa2lca taxonomy taxa2tree protinfo]
Expand Down
8 changes: 6 additions & 2 deletions config/deploy/dev.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Example: cap dev deploy server=patty.taild1497.ts.net

set :stage, :dev

set :deploy_to, '/home/unipept/rails'

set :server, ENV['server'] || 'patty.ugent.be'

# don't specify db as it's not needed for unipept
server 'sherlock.ugent.be', user: 'unipept', roles: %i[web app], ssh_options: {
server "#{fetch(:server)}", user: 'unipept', roles: %i[web app], ssh_options: {
port: 4840
}

set :branch, 'feature/pept2filtered'
set :branch, 'fix/options_request_api'
set :rails_env, :development

namespace :deploy do
Expand Down
2 changes: 2 additions & 0 deletions config/deploy/prod.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Example: cap prod deploy server=patty.taild1497.ts.net

set :stage, :prod

set :deploy_to, '/home/unipept/rails'
Expand Down
6 changes: 5 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Rails.application.routes.draw do
# General inforamtion
# General information
scope :private_api, as: 'private_api' do
match "/*path", via: [:options], :to => "handle_options#handle_options_request"
match "goterms", via: [:get, :post], :to => "private_api#goterms"
Expand All @@ -20,6 +20,10 @@
match 'sampledata', via: [:post], to: 'datasets#sampledata'
end

scope :api, as: 'api' do
match '/*path', via: [:options], to: 'handle_options#handle_options_request'
end

namespace :api, path: 'api/v1' do
match 'pept2taxa' => "api#pept2taxa", via: %i[get post]
match 'pept2lca' => "api#pept2lca", via: %i[get post]
Expand Down

0 comments on commit 3c038ab

Please sign in to comment.