cellkit

module
v0.0.0-...-927f8ed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2022 License: GPL-3.0

README

cellkit


!!! This repository is no longer in development. For the new cell module, visit this repository !!!


Cellkit is a module that facilitates the creation of HLHV cells. In the future, this module will contain many convenience functions to make creating a cell easier.

Client

The client package exposes basic functions for connecting to a queen cell and handling incoming requests. Below is a basic program utilizing the client functionality:

package main

import (
        "github.com/hlhv/protocol"
        "github.com/hlhv/cellkit/frame"
        "github.com/hlhv/cellkit/client"
)

func main () {
        // configure framework
        frame.Be (&frame.Conf {
                Description: "Test cell",
                Run:         run,
        })
}

// main cell function
func run (leash *client.Leash) {
        leash.OnHTTP(onHTTP)
        
        // connect to server
        leash.Ensure (
                "localhost:2001",

                // mount on the root. @ refers to the default hostname, which
                // localhost is aliased to by default.
                client.Mount { "@", "/" },
                "something",
                "",
        )
}

// http request handler
func onHTTP (
        band *client.Band,
        head *protocol.FrameHTTPReqHead,
) {
        // passing nil writes no headers
        band.WriteHTTPHead(200, nil)
        
        // write response body
        band.WriteHTTPBody([]byte("hello, world!"))
}

This program will respond to any incoming HTTP request with the text "hello world!".

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL