mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-18 15:33:02 +00:00
Add docstrings and remove request_received
This commit is contained in:
@@ -15,41 +15,33 @@ from jupyterhub.services.auth import HubAuthenticated
|
|||||||
|
|
||||||
|
|
||||||
class EchoHandler(web.RequestHandler):
|
class EchoHandler(web.RequestHandler):
|
||||||
def data_received(self, chunk):
|
"""Handler that mocks a request to the tornado webserver"""
|
||||||
pass
|
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
self.write(self.request.path)
|
self.write(self.request.path)
|
||||||
|
|
||||||
|
|
||||||
class EnvHandler(web.RequestHandler):
|
class EnvHandler(web.RequestHandler):
|
||||||
def data_received(self, chunk):
|
"""Handler that mocks a request using header and environment settings"""
|
||||||
pass
|
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
self.set_header('Content-Type', 'application/json')
|
self.set_header('Content-Type', 'application/json')
|
||||||
self.write(json.dumps(dict(os.environ)))
|
self.write(json.dumps(dict(os.environ)))
|
||||||
|
|
||||||
|
|
||||||
class APIHandler(web.RequestHandler):
|
class APIHandler(web.RequestHandler):
|
||||||
def data_received(self, chunk):
|
"""Handler that mocks a request using an API token"""
|
||||||
pass
|
|
||||||
|
|
||||||
def get(self, path):
|
def get(self, path):
|
||||||
api_token = os.environ['JUPYTERHUB_API_TOKEN']
|
api_token = os.environ['JUPYTERHUB_API_TOKEN']
|
||||||
api_url = os.environ['JUPYTERHUB_API_URL']
|
api_url = os.environ['JUPYTERHUB_API_URL']
|
||||||
r = requests.get(api_url + path, headers={
|
r = requests.get(api_url + path,
|
||||||
'Authorization': 'token %s' % api_token
|
headers={'Authorization': 'token %s' % api_token},
|
||||||
})
|
)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
self.set_header('Content-Type', 'application/json')
|
self.set_header('Content-Type', 'application/json')
|
||||||
self.write(r.text)
|
self.write(r.text)
|
||||||
|
|
||||||
|
|
||||||
class WhoAmIHandler(HubAuthenticated, web.RequestHandler):
|
class WhoAmIHandler(HubAuthenticated, web.RequestHandler):
|
||||||
def data_received(self, chunk):
|
"""Handler that mocks a request with an authenticated user"""
|
||||||
pass
|
|
||||||
|
|
||||||
@web.authenticated
|
@web.authenticated
|
||||||
def get(self):
|
def get(self):
|
||||||
self.write(self.get_current_user())
|
self.write(self.get_current_user())
|
||||||
|
Reference in New Issue
Block a user