Help us shape the future of Go! Take the 2026 Go Developer Survey

tea

package module
v0.0.0-...-ccfb302 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: MIT Imports: 10 Imported by: 0

README

tea

An experimental web-framework in Go.

package main

import (
	"fmt"
	"net/http"

	"github.com/marconi/tea"
)

func main() {
	t := tea.New()
	t.Get("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintln(w, "Hello World!")
	})

	t.Logger.Fatalln(t.Start("localhost:8080"))
}

Output:

INFO[2019-03-05T09:25:17+08:00] 🍵  is served on localhost:8080  

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Infof(string, ...interface{})
}

type Middleware

type Middleware func(http.Handler) http.Handler

func NewBasicAuthMiddleware

func NewBasicAuthMiddleware(realm string, authFunc authenticator, authorizeFunc authorizator) Middleware

func NewLoggingMiddleware

func NewLoggingMiddleware(loggers ...Logger) Middleware

An un-customizable logging middleware

type ResponseWriter

type ResponseWriter interface {
	http.ResponseWriter
	Status() int
}

strip down version of https://godoc.org/github.com/codegangsta/negroni#ResponseWriter at the moment it only supports recording of status

func NewResponseWriter

func NewResponseWriter(rw http.ResponseWriter) ResponseWriter

type Tea

type Tea struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

func New

func New() *Tea

func (*Tea) Apply

func (t *Tea) Apply(h http.HandlerFunc, middlewares ...Middleware) http.HandlerFunc

func (*Tea) Get

func (t *Tea) Get(path string, h http.HandlerFunc)

func (*Tea) ServeHTTP

func (t *Tea) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Tea) Start

func (t *Tea) Start(addr string) error

func (*Tea) Use

func (t *Tea) Use(h Middleware)

Jump to

Keyboard shortcuts

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