indigo

package module
v1.4.0-beta Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 14 Imported by: 0

README

drawing

Indigo is non-idiomatic, but focusing on simplicity and performance web-server

It provides such a features:

  • Streaming-based body processing
  • Server-wide settings
  • Response object constructor
  • Middlewares
  • Endpoint groups
  • Connection hijacking

Hello, world!

package main

import (
  "context"
  "log"
  
  "github.com/fakefloordiv/indigo"
  "github.com/fakefloordiv/indigo/router/inbuilt"
  "github.com/fakefloordiv/indigo/types"
)

var addr = "localhost:9090"

func MyHandler(_ context.Context, req *types.Request) types.Response {
  return types.WithBody("Hello, world!")
}

func main() {
  router := inbuilt.NewRouter()
  router.Get("/", MyHandler)

  app := indigo.NewApp(addr)
  log.Fatal(app.Serve(router))
}

More examples in examples/ folder.

Project workspace (TODO list included): trello.com/w/indigowebserver

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

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

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

func NewApp

func NewApp(addr string) *Application

NewApp returns a new application object with initialized shutdown chan

func (Application) AddContentDecoder

func (a Application) AddContentDecoder(token string, decoder encodings.Decoder)

AddContentDecoder simply adds a new content decoder

func (Application) Serve

func (a Application) Serve(r router.Router, settings ...settings2.Settings) error

Serve takes a router and someSettings, that must be only 0 or 1 elements otherwise, error is returned Also, if specified, Accept-Encodings default header's value will be set here

func (*Application) SetDefaultHeaders

func (a *Application) SetDefaultHeaders(headers map[string][]string)

SetDefaultHeaders overrides default headers to a passed ones. Doing this, make sure you know what are you doing

func (Application) Shutdown

func (a Application) Shutdown()

Shutdown gracefully shutting down the server. It is not blocking, server being shut down right after calling this method is not guaranteed, because tcp server will wait for the next connection, and only then he'll be able to receive a shutdown notify. Moreover, tcp server will wait until all the existing connections will be closed

func (Application) Wait

func (a Application) Wait()

Wait waits for tcp server to shut down

Jump to

Keyboard shortcuts

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