Share your repls and programming experiences

← Back to all posts
CookeyLang HTTP Server
h
Coder100 (17111)

HTTP server

This is the example of the HTTP server implementation of CookeyLang. Special thanks to #13.

Methods

The API is ridiculously simple!

class Http {
  construct(method:
    (
      method: string,
      url: string,
      res: (data: string): void
    ): void
  );

  listen(port: number);
}

Usage

In general, you would do something like this:

include("http");

function callback(method, url, res) {
  res("Hello, world!");
}

Http(callback).listen(8080);

Because cookeylang doesn't have any anonymous functions (yet), you will have to either use a lambda or a callback function.

Future

Making an HTTP server like this is actually quite complex, as there are many things not yet implemented that will require more CookeyLang3 features. Namely hashmaps and static methods.

Closing

Thanks for viewing this repl! CookeyLang is on its way to taking over the world!