Wednesday | 04 DEC 2024
[ previous ]
[ next ]

Seraphim Design Choices

Title:
Date: 2024-03-23
Tags:  pick, basic

I've made a small but breaking change to the way my web server, SERAPHIM works. It originally would run in the foreground and you would pass in the application name. The idea was that you would write a config file in the BOOK-OF-LIFE that would contain the various things you need to launch an application. It had the port number, the ip address to listen on, the ssl certificate paths and most importantly the routes.

My goal was to eventually write a front end entry routine so you could manage this stuff so that you don't have to mess with the config file directly.

I've grown less fond of this design and I've switched SERAPHIM to now be a subroutine call. Now the way to use SERAPHIM is to call it and pass in each of the information. This lets me move the configuration into a BASIC program. I like this idea because now the configuration is directly in the program and I compile the program to add and remove things. This is a bit of a hassle but it does mean there is just one place to look and it looks just like any other BASIC program.

There is no overhead with trying to figure out what the configuration file is supposed to look like or even where it is. Now everything is in one place and in my eyes its much simpler to see how things are getting mapped.

Below is an example of an application using SERAPHIM. I think this is more intuitive than knowing to update the BOOK-OF-LIFE and filling in the information.

*
   SERVER.PORT = ''
*
   SERVER.IP = '0.0.0.0'
   SERVER.PORT = '7121'
*
   SSL = ''
*
   GOSUB SETUP.ROUTES
*
   CALL SERAPHIM(SERVER.IP,SERVER.PORT,SSL,ROUTES)
*
   STOP
*
*********************  S U B R O U T I N E  *********************
*
SETUP.ROUTES:NULL
*
   ROUTES = ''
*
   ROUTES<1,-1> = '/'
   ROUTES<2,-1> = 'WEB.INDEX'
*
   ROUTES<1,-1> = '/login'
   ROUTES<2,-1> = 'WEB.LOGIN'
*
   ROUTES<1,-1> = '/logout'
   ROUTES<2,-1> = 'WEB.LOGIN'
*
   RETURN
*
* END OF PROGRAM
*
   END
*

This required me to change my BITE-THE-APPLE starter routine and the METATRON routine that manages SERAPHIM. There is still some clean up to be done but for now everything is useable and working.

I still want to clean up the actual request handles as well as that is also a bit weird to write in. There is boilerplate that I think can be made an include that will cut down how messy it looks.