source: TFP-WebServer/WebServer/src/UrlHandlers/AbsHandler.cs@ 454

Last change on this file since 454 was 440, checked in by alloc, 18 months ago

*Added: Allow specifying a single level 0 API token on the command line

File size: 918 bytes
RevLine 
[404]1using Webserver.Permissions;
2
[391]3namespace Webserver.UrlHandlers {
4 public abstract class AbsHandler {
[434]5 public readonly string ModuleName;
[391]6 protected string urlBasePath;
7 protected Web parent;
8
9 public string UrlBasePath => urlBasePath;
10
11 protected AbsHandler (string _moduleName, int _defaultPermissionLevel = 0) {
[434]12 ModuleName = _moduleName;
[426]13 AdminWebModules.Instance.AddKnownModule (new AdminWebModules.WebModule(_moduleName, _defaultPermissionLevel, true));
[391]14 }
15
16 public abstract void HandleRequest (RequestContext _context);
17
[440]18 public virtual bool IsAuthorizedForHandler (RequestContext _context) {
19 return ModuleName == null || AdminWebModules.Instance.ModuleAllowedWithLevel (ModuleName, _context.PermissionLevel);
[391]20 }
21
22 public virtual void Shutdown () {
23 }
24
25 public virtual void SetBasePathAndParent (Web _parent, string _relativePath) {
26 parent = _parent;
27 urlBasePath = _relativePath;
28 }
29 }
30}
Note: See TracBrowser for help on using the repository browser.