http

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package http provides a static file server using embedded files in Go. This code is inspired by a pull request in the gin-contrib/static library. Reference: https://github.com/gin-contrib/static/pull/20/files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Embed

func Embed(targetPath string, placeholderValues map[string]string, regex bool) static.ServeFileSystem

Embed is a function that takes a target path as an argument and returns an implementation of the static.ServeFileSystem interface, which can be used with a Gin router to serve static files from the embedded file system. The embedded file system is defined by the "static" directory in the embedded files (using the `//go:embed` directive).

func Serv

func Serv(
	addr string,
	cache *db.Cache,
	placeHolderValues map[string]string,
	chHandler NewChannelHandler,
) error

Serv starts an HTTP server at the specified address and handles incoming requests. It takes a callback function handleNewChannel which is called when a new WebSocket channel is established.

Types

type Channel

type Channel struct {
	Addr  string   // email address for this channel
	Conn  net.Conn // ws connection
	Alive bool
}

Channel represents a websocket channel for a specific email address.

func (*Channel) Close

func (c *Channel) Close()

Close closes the websocket channel.

func (*Channel) Write

func (c *Channel) Write(message db.Message) error

Write writes a message to the websocket channel.

type NewChannelHandler

type NewChannelHandler func(channel *Channel)

Directories

Path Synopsis
Package rfs provides a custom http.FileSystem implementation for serving files with placeholders replaced by their corresponding values.
Package rfs provides a custom http.FileSystem implementation for serving files with placeholders replaced by their corresponding values.

Jump to

Keyboard shortcuts

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