src/dictionaryserver

dictionaryserver

This module houses the webserver to send POST and GET requests to.

Consts

port {.intdefine.}: uint16 = 6969
Server port

Procs

proc handleNewDefinition(request: Request; path: seq[string]): owned(
    Future[void]) {....stackTrace: false, raises: [Exception],
                    tags: [DbEffect, ReadDbEffect, WriteDbEffect, RootEffect],
                    forbids: [].}
Processes a submission and serves a success/failure page
proc handleRequest(request: Request): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, DbEffect, ReadDbEffect, WriteDbEffect], forbids: [].}
Main request handler based on path
proc responseHeaders(): HttpHeaders {....raises: [KeyError], tags: [], forbids: [].}
Default http headers
proc runServer(): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [
    WriteIOEffect, ReadIOEffect, RootEffect], forbids: [].}
Runs the server - listens to requests and responds
proc serveDefinitionById(request: Request; path: seq[string]): owned(
    Future[void]) {....stackTrace: false, raises: [Exception],
                    tags: [RootEffect, DbEffect, ReadDbEffect, WriteDbEffect],
                    forbids: [].}
Serves a definition queried by its ID
proc serveDefinitions(request: Request; path: seq[string]): owned(
    Future[void]) {....stackTrace: false, raises: [Exception],
                    tags: [RootEffect, DbEffect, ReadDbEffect, WriteDbEffect],
                    forbids: [].}
Queries all definitions or by patterns
proc serveErrorPage(request: Request; path: seq[string]; description: string;
                    httpCode: HttpCode = Http400): owned(Future[void]) {.
    ...stackTrace: false, raises: [Exception], tags: [RootEffect], forbids: [].}
Generic error page server
proc serveIndex(request: Request; path: seq[string]): owned(Future[void]) {.
    ...stackTrace: false, raises: [Exception],
    tags: [RootEffect, DbEffect, ReadDbEffect, WriteDbEffect], forbids: [].}
Serves the index page
proc serveNewEntryConstruct(request: Request; path: seq[string]): owned(
    Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect],
                    forbids: [].}
Serves a page for a new entry