CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cvmfs_api.py
Go to the documentation of this file.
1 import os
2 import cvmfs_geo
3 
4 positive_expire_secs = 60*60 # 1 hour
5 negative_expire_secs = 60*5; # 5 minutes
6 
7 def bad_request(start_response, reason):
8  response_body = 'Bad Request: ' + reason + "\n"
9  start_response('400 Bad Request',
10  [('Cache-control', 'max-age=' + str(negative_expire_secs)),
11  ('Content-Length', str(len(response_body)))])
12  return [response_body.encode('utf-8')]
13 
14 def good_request(start_response, response_body):
15  start_response('200 OK',
16  [('Content-Type', 'text/plain'),
17  ('Cache-control', 'max-age=' + str(positive_expire_secs)),
18  ('Content-Length', str(len(response_body)))])
19  return [response_body.encode('utf-8')]
20 
21 def dispatch(api_func, path_info, repo_name, version, start_response, environ):
22  if api_func == 'geo':
23  return cvmfs_geo.api(path_info, repo_name, version, start_response, environ)
24 
25  return bad_request(start_response, 'unrecognized api function')
def good_request
Definition: cvmfs_api.py:14
def dispatch
Definition: cvmfs_api.py:21
def bad_request
Definition: cvmfs_api.py:7