-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make data limits a permanent feature #698
Changes from 6 commits
a7fd50c
6ad2e2c
64caffc
654547e
d379d31
cb67732
40b529b
f1c5e8d
b89ca61
482152e
66da29b
1397e50
f84e99c
765268e
ae906a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,10 @@ export function bindService( | |
apiServer: restify.Server, apiPrefix: string, service: ShadowsocksManagerService) { | ||
apiServer.put(`${apiPrefix}/name`, service.renameServer.bind(service)); | ||
apiServer.get(`${apiPrefix}/server`, service.getServer.bind(service)); | ||
apiServer.put( | ||
`${apiPrefix}/server/access-key-data-limit`, service.setAccessKeyDataLimit.bind(service)); | ||
apiServer.del( | ||
`${apiPrefix}/server/access-key-data-limit`, service.removeAccessKeyDataLimit.bind(service)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it's good to model features as a resource like we do with access keys ( Ideally, I think it would be nice to have something broken down by component like:
But that might not be possible to shoehorn to our current scheme. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a way we already do this: the access key data limit is a property of the server (resource). I like the idea of formalizing the hierarchy. |
||
apiServer.put( | ||
`${apiPrefix}/server/hostname-for-access-keys`, | ||
service.setHostnameForAccessKeys.bind(service)); | ||
|
@@ -94,13 +98,21 @@ export function bindService( | |
apiServer.get(`${apiPrefix}/metrics/enabled`, service.getShareMetrics.bind(service)); | ||
apiServer.put(`${apiPrefix}/metrics/enabled`, service.setShareMetrics.bind(service)); | ||
|
||
// Experimental APIs | ||
// Redirect former experimental APIs | ||
apiServer.put( | ||
`${apiPrefix}/experimental/access-key-data-limit`, | ||
service.setAccessKeyDataLimit.bind(service)); | ||
redirect(`${apiPrefix}/server/access-key-data-limit`)); | ||
apiServer.del( | ||
`${apiPrefix}/experimental/access-key-data-limit`, | ||
service.removeAccessKeyDataLimit.bind(service)); | ||
redirect(`${apiPrefix}/server/access-key-data-limit`)); | ||
} | ||
|
||
// Returns a request handler that redirects a bound request path to `url` with HTTP status code 308. | ||
function redirect(url: string): restify.RequestHandlerType { | ||
return (req: restify.Request, res: restify.Response, next: restify.Next) => { | ||
logging.debug(`Redirecting ${req.url} => ${url}`); | ||
res.redirect(308, url, next); | ||
}; | ||
} | ||
|
||
function validateAccessKeyId(accessKeyId: unknown): string { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: should we reformat this across across several lines? It's difficult for me to read on my laptop screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We lost the formatting during the polymer upgrade. We should look into a way of automating formatting for these mixed (html + css + js) files.