janus

package module
v0.0.0-...-1d3fc3b Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 14 Imported by: 1

README

Janus: The many faced framework

Janus is a modular framework for Go web applications.

It is made up of several interfaces (hence "many faced") which can be picked-and-used as required. Each interface will come with several implementations, so the user does not have to write their own implementation unless necessary.

A work in progress...

Philosophy

The general advice in the Go community is to use the standard library as much as possible and not jump into frameworks.

However, most Go frameworks I've seen are heavily opinionated which means that unless you being with them, or convert almost all your code to be compatible with it, you can't really use the framework. It also makes it hard to remove if neccessary.

The purpose of Janus is to have a set of interfaces that rely mostly on the stdlib, with various implementations of these interfaces.

These interfaces should help with:

  • Routing
  • Rendering
  • Authentication
  • Migration
  • Object storage

...more in the future

A user can then pick what parts they want to use and drop it into their application.

The dependence on the stdlib also makes it super easy to remove any unnecessary part of the framework and either use a compatible library, or the stdlib itself.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger logger = log.New(os.Stderr, "", log.LstdFlags)

Logger to print lgos

Functions

func NoopStopFunc

func NoopStopFunc(_ context.Context) error

func Stop

func Stop(ctx context.Context, timeout time.Duration, stop StopFunc)

func WriteError

func WriteError(w http.ResponseWriter, r *http.Request, err error, code int)

WriteError is a helper to return an error

Types

type Broker

type Broker struct {
	Domains   []string
	Templates executor.Executor
	Assets    http.FileSystem
	Auth      auth.Authenticator
	Monitor   monitor.Monitor

	CSRFMiddleware middlewares.CSRF
}

Broker contains all our routes and handlers and can return a handler for our http.Server

func (*Broker) GetCSRFToken

func (b *Broker) GetCSRFToken(r *http.Request) string

GetCSRFToken to use for subsequet requests

func (Broker) RecommendedMiddlewares

func (b Broker) RecommendedMiddlewares() []mid

RecommendedMiddlewares for our handler

func (*Broker) SetAssets

func (b *Broker) SetAssets(s http.FileSystem)

SetAssets for our handler

func (*Broker) SetAuth

func (b *Broker) SetAuth(a auth.Authenticator)

SetAuth for our handler

func (*Broker) SetDomains

func (b *Broker) SetDomains(d []string)

SetDomains for our handler

func (*Broker) SetTemplates

func (b *Broker) SetTemplates(t executor.Executor)

SetTemplates for our handler

type StopFunc

type StopFunc = func(context.Context) error

func CombineStopFuncs

func CombineStopFuncs(stops ...StopFunc) StopFunc

func NoContextStopFunc

func NoContextStopFunc(f func() error) StopFunc

Jump to

Keyboard shortcuts

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