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

Last change on this file since 460 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
Line 
1using Webserver.Permissions;
2
3namespace Webserver.UrlHandlers {
4 public abstract class AbsHandler {
5 public readonly string ModuleName;
6 protected string urlBasePath;
7 protected Web parent;
8
9 public string UrlBasePath => urlBasePath;
10
11 protected AbsHandler (string _moduleName, int _defaultPermissionLevel = 0) {
12 ModuleName = _moduleName;
13 AdminWebModules.Instance.AddKnownModule (new AdminWebModules.WebModule(_moduleName, _defaultPermissionLevel, true));
14 }
15
16 public abstract void HandleRequest (RequestContext _context);
17
18 public virtual bool IsAuthorizedForHandler (RequestContext _context) {
19 return ModuleName == null || AdminWebModules.Instance.ModuleAllowedWithLevel (ModuleName, _context.PermissionLevel);
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.