indigo

package module
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: MIT Imports: 20 Imported by: 1

README

This is just a logo

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

Documentation

Documentation is available here. However, it isn't complete yet.

Hello, world!

package main

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

const (
  addr = "0.0.0.0"
  port = 8080
)

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

func main() {
  router := inbuilt.New()
  router.Resource("/").
    Get(MyHandler).
    Post(MyHandler)

  app := indigo.NewApp(addr, port)
  if err := app.Serve(router); err != nil {
    log.Fatal(err)
  }
}

More examples in examples/ folder.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHeaders = map[string][]string{

	"Accept-Encodings": nil,
}

DefaultHeaders are headers that are going to be sent unless they were overridden by user.

WARNING: if you want to edit them, do it using Application.AddDefaultHeader or Application.DeleteDefaultHeader instead

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) AddCoding added in v0.10.4

func (a *Application) AddCoding(constructor coding.Constructor)

AddCoding adds a new content coding, available for both encoding and decoding

func (*Application) AddDefaultHeader

func (a *Application) AddDefaultHeader(key string, values ...string)

func (*Application) DeleteDefaultHeader

func (a *Application) DeleteDefaultHeader(key string)

func (*Application) GracefulShutdown added in v0.10.1

func (a *Application) GracefulShutdown()

GracefulShutdown stops the application peacefully. It stops a listener, so no more clients will be able to connect, but all the already connected will be processed till end (till the last one disconnects)

func (*Application) Serve

func (a *Application) Serve(r router.Router, optionalSettings ...settings.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) Stop added in v0.10.1

func (a *Application) Stop()

Jump to

Keyboard shortcuts

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