{"action":"created","issue":{"url":"https://api.github.com/repos/aura-project/aura/issues/430","repository_url":"https://api.github.com/repos/aura-project/aura","labels_url":"https://api.github.com/repos/aura-project/aura/issues/430/labels{/name}","comments_url":"https://api.github.com/repos/aura-project/aura/issues/430/comments","events_url":"https://api.github.com/repos/aura-project/aura/issues/430/events","html_url":"https://github.com/aura-project/aura/issues/430","id":176932948,"number":430,"title":"Improving the Web Server","user":{"login":"exectails","id":5593920,"avatar_url":"https://avatars.githubusercontent.com/u/5593920?v=3","gravatar_id":"","url":"https://api.github.com/users/exectails","html_url":"https://github.com/exectails","followers_url":"https://api.github.com/users/exectails/followers","following_url":"https://api.github.com/users/exectails/following{/other_user}","gists_url":"https://api.github.com/users/exectails/gists{/gist_id}","starred_url":"https://api.github.com/users/exectails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exectails/subscriptions","organizations_url":"https://api.github.com/users/exectails/orgs","repos_url":"https://api.github.com/users/exectails/repos","events_url":"https://api.github.com/users/exectails/events{/privacy}","received_events_url":"https://api.github.com/users/exectails/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aura-project/aura/labels/discussion","name":"discussion","color":"f5f5f5"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-09-14T15:06:56Z","updated_at":"2016-09-24T09:22:20Z","closed_at":null,"body":"When we originally added the web server all we wanted was an easy way to add a simple API for the actual server's site and maybe tools to use, and some simple sites, like for guilds, to do basic tasks you can't do in-game.\r\n\r\nOver the last months I came to the realization that there's no reason to sell the web server short. It's good enough to run small to medium sized websites on, and even if not for that, it could still be used for prototyping or temporary access to scripts like the registration. The server is there, always running, so why not use it?\r\n\r\nHowever, the current web server has a problem when it comes to extensibility. Not only is it complicated to add new pages, it's even harder to override existing ones, and it's currently impossible to override existing assets, like images and css files.\r\n\r\nI'd like to replace our current web server, which uses routing, with one that has a more classic approach. Instead of loading scripts that set up their own routes to make them accessible, you'd simply move the script file to the web folder. Done.\r\n\r\nFor example, this is part of our registration script.\r\n\r\n```\r\npublic class RegistrationControllerScript : IScript\r\n{\r\n\tpublic bool Init()\r\n\t{\r\n\t\tWebServer.Instance.App.All(\"/register\", (req, res) =>\r\n\t\t{\r\n\t\t\t// ...\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\nThis goes into a file, you put that file into the script folder, add it to the web script list, and then you can access it via \"<url>/register\". To change something like the URL, you'd have to modify the script.\r\n\r\nWhat I'm imagining is writing the following, putting it into a file, and simply moving that file to the web folder, wherever I want the file to be.\r\n\r\n```\r\npublic class RegistrationControllerScript : IScript\r\n{\r\n\tpublic void OnRequest(Request req, Response res)\r\n\t{\r\n\t\t// ...\r\n\t}\r\n}\t\r\n```\r\n\r\nAs soon as it's in the folder, you can access it via \"<url>/register.cs\" for example, or whatever *you* called the file. It's a simple file serving web server, with support for C# scripting. Every file *you* move to the web folder becomes accessible. All integrated with the user folder of course, that's treated with higher priority, so you can replace system scripts, images, templates, CSS files, etc.\r\n\r\nWith this setup we could also easily support other scripting languages if we wanted to, like PHP. It could be possible to run any PHP software, like forums, from our server.\r\n\r\nSounds like I'm trying to sell something innovative here, when it's really the old-school way of handling web requests =P I've made a [prototype](https://github.com/exectails/Swebs) a while ago, and it really wouldn't be all that hard to switch them out.\r\n\r\nTheoretically the user system could work with the current web server as well, overriding pages, scripts, and files could be made possible, but I'm thinking the current web server is not exactly user friendly. You can't even put a simple HTML file on it without knowing exactly where to put it, and even if that's made easier we would have 2 separate systems at work, static file serving and the script list.\r\n\r\nNot to mention, what if you download something like a CMS that is supposed to run on Aura's web server? It needs to go into the right folder, the scripts need to be added to the list, there could be conflicts in the paths, because the scripts decide them, it's problematic in my eyes.\r\n\r\nTell me what you think!"},"comment":{"url":"https://api.github.com/repos/aura-project/aura/issues/comments/249355016","html_url":"https://github.com/aura-project/aura/issues/430#issuecomment-249355016","issue_url":"https://api.github.com/repos/aura-project/aura/issues/430","id":249355016,"user":{"login":"exectails","id":5593920,"avatar_url":"https://avatars.githubusercontent.com/u/5593920?v=3","gravatar_id":"","url":"https://api.github.com/users/exectails","html_url":"https://github.com/exectails","followers_url":"https://api.github.com/users/exectails/followers","following_url":"https://api.github.com/users/exectails/following{/other_user}","gists_url":"https://api.github.com/users/exectails/gists{/gist_id}","starred_url":"https://api.github.com/users/exectails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exectails/subscriptions","organizations_url":"https://api.github.com/users/exectails/orgs","repos_url":"https://api.github.com/users/exectails/repos","events_url":"https://api.github.com/users/exectails/events{/privacy}","received_events_url":"https://api.github.com/users/exectails/received_events","type":"User","site_admin":false},"created_at":"2016-09-24T09:22:20Z","updated_at":"2016-09-24T09:22:20Z","body":"I've switched from SharpExpress to Swebs in a branch, it would be good if those interested in the web server could take a look at it, see how you like it.\r\n\r\nhttps://github.com/aura-project/aura/tree/add-swebs\r\nhttps://github.com/aura-project/aura/tree/add-swebs/system/web\r\nhttps://github.com/aura-project/aura/blob/add-swebs/src/WebServer/WebServer.cs#L96\r\n\r\nAs you can see in the system's web directory, all web files are now in this one folder, with the web server acting like a traditional web server, all files in there being accessible. And as described above, Swebs first looks at the user's web folder for files, so you can easily replace images, styles, etc. just by putting them there.\r\n\r\nNew pages can be added the same way, by simply placing them in one of the web folders.\r\n\r\nThere's no access rules or rewriting yet, but I think those are secondary."}}
{"actor":{"display_login":"exectails"}}