Skip to content
This repository was archived by the owner on Jul 7, 2022. It is now read-only.

hlhv/cellkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!".

Releases

No releases published

Packages

No packages published

Languages