indigo

package module
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2025 License: MIT Imports: 22 Imported by: 1

README

indigo

image

Elegance, conciseness, flexibility and extensibility — that’s what Indigo is about. The goal is to create a mini ecosystem in which you can focus on actual tasks rather than reimplementing the same things over and over again. Everything you need to get started is already included, and whatever isn’t is trivially pluggable.

FastHTTP-grade performance, stream-based body processing, fine-tuning of nearly every parameter — including memory consumption control — and a full-fledged built-in router are the icing on the cake.

Documentation

Documentation is available here. It might be incomplete however, feel free to open issues.

Hello, world!

package main

import (
	"log"

	"github.com/indigo-web/indigo"
	"github.com/indigo-web/indigo/http"
	"github.com/indigo-web/indigo/router/inbuilt"
)

func HelloWorld(request *http.Request) *http.Response {
	return http.String(request, "Hello, world!")
}

func Log(request *http.Request) *http.Response {
	text, err := request.Body.String()
	if err != nil {
		return http.Error(request, err)
	}

	log.Printf("%s says: %s", request.Remote, text)
	return http.String(request, text)
}

func main() {
	r := inbuilt.New()
	r.Resource("/").
		Get(HelloWorld).
		Post(Log)

	err := indigo.New(":8080").Serve(r)
	if err != nil {
		log.Fatal(err)
	}
}

You can find more examples in examples/.

Documentation

Index

Constants

View Source
const Version = "0.17.3"

Variables

This section is empty.

Functions

func Cert added in v0.17.0

func Cert(cert, key string) tls.Certificate

Cert loads the TLS certificate. Panics if an error happened.

func LocalCert added in v0.17.0

func LocalCert(cache ...string) tls.Certificate

LocalCert issues a self-signed certificate for local TLS-secured connections. Please note, that self-signed certificates are failing security checks, so browsers and tools (e.g. curl) may refuse to connect without adding security check skip flags (in particular, -k or --insecure for curl.)

Types

type App added in v0.15.0

type App struct {
	// contains filtered or unexported fields
}

App is just a struct with addr and shutdown channel that is currently not used. Planning to replace it with context.WithCancel()

func New added in v0.15.0

func New(addr string) *App

New returns a new App instance.

func (*App) Codec added in v0.17.2

func (a *App) Codec(codecs ...codec.Codec) *App

Codec appends a new codec into the list of supported.

func (*App) Listen added in v0.15.0

func (a *App) Listen(addr string, ts ...Transport) *App

func (*App) OnBind added in v0.16.0

func (a *App) OnBind(cb func(addr string)) *App

OnBind callback is called every time a listener is ready to accept new connections.

func (*App) OnStart added in v0.16.0

func (a *App) OnStart(cb func()) *App

OnStart calls the callback at the moment, when all the servers are started. However, it isn't strongly guaranteed that they'll be able to accept new connections immediately.

func (*App) OnStop added in v0.16.0

func (a *App) OnStop(cb func()) *App

OnStop calls the callback at the moment, when all the servers are down. It's guaranteed, that at the moment as the callback is called, the server isn't able to accept any new connections and all the clients are already disconnected.

func (*App) Serve added in v0.15.0

func (a *App) Serve(r router.Builder) error

Serve starts the web-application. If nil is passed instead of a router, empty inbuilt will be used.

func (*App) Stop added in v0.15.0

func (a *App) Stop()

Stop stops the whole application immediately and waits until it _really_ stops.

func (*App) TLS added in v0.15.0

func (a *App) TLS(addr string, certs ...tls.Certificate) *App

TLS is a shortcut for App.Listen(addr, indigo.TLS(indigo.Cert(cert, key))).

Starts an TLS listener on the provided address using provided 1 or more certificates. Zero passed certificates will panic.

func (*App) Tune added in v0.15.0

func (a *App) Tune(cfg *config.Config) *App

Tune replaces default config.

type Transport added in v0.17.0

type Transport struct {
	// contains filtered or unexported fields
}

func Autocert added in v0.17.0

func Autocert(domains ...string) Transport

Autocert tries to automatically issue a certificate for the given domains. If operation succeeds, those will be (hopefully) saved into the default cache directory, which depends on the OS. If you want to specify the cache directory, use AutocertWithCache instead.

func AutocertWithCache added in v0.17.0

func AutocertWithCache(cache string, domains ...string) Transport

AutocertWithCache tries to automatically issue a certificate for the given domains. If the operation succeeds, those will be (hopefully) saved into the provided cache directory. It's recommended to use Autocert if there are no explicit needs to set custom cache directory.

func TCP added in v0.17.0

func TCP() Transport

func TLS added in v0.17.0

func TLS(certs ...tls.Certificate) Transport

Jump to

Keyboard shortcuts

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