seni

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 10 Imported by: 0

README

Seni

Seni is a simple fiber-like web framework written in Golang.

The Japanese word "Seni" is pronounced as "Sen-ee" in English.

Quickstart

package main

import "github.com/demouth/seni"

func main() {
	app := seni.New()

	// GET / --> "Hello, World 👋!"
	app.Get("/", func(c *seni.Ctx) {
		c.Status(200)
		c.Write("Hello, World 👋!")
	})

	app.Listen(":3000")
}

Examples

package main

import "github.com/demouth/seni"

func main() {
	app := seni.New()

	// GET / --> "Hello, World 👋!"
	app.Get("/", func(c *seni.Ctx) {
		c.Status(200)
		c.Write("Hello, World 👋!")
	})

	v1 := app.Group("/v1", func(c *seni.Ctx) {
		c.Write("Hello ")
		c.Next()
	})

	// GET /v1/hello/john/and/doe --> "Hello john and doe"
	v1.Get("/hello/:param/and/:param2", func(c *seni.Ctx) {
		c.Status(200)
		c.Write(c.Params("param") + " and " + c.Params("param2"))
	})

	app.Listen(":3000")
}

Documentation

Index

Constants

View Source
const (
	MethodGet     = "GET"     // RFC 7231, 4.3.1
	MethodHead    = "HEAD"    // RFC 7231, 4.3.2
	MethodPost    = "POST"    // RFC 7231, 4.3.3
	MethodPut     = "PUT"     // RFC 7231, 4.3.4
	MethodPatch   = "PATCH"   // RFC 5789
	MethodDelete  = "DELETE"  // RFC 7231, 4.3.5
	MethodConnect = "CONNECT" // RFC 7231, 4.3.6
	MethodOptions = "OPTIONS" // RFC 7231, 4.3.7
	MethodTrace   = "TRACE"   // RFC 7231, 4.3.8
)

HTTP methods were copied from net/http.

Variables

This section is empty.

Functions

func TrimRight

func TrimRight(s string, cutset byte) string

func TrimRightBytes

func TrimRightBytes(b []byte, cutset byte) []byte

TrimRightBytes is the equivalent of bytes.TrimRight

Types

type Ctx

type Ctx struct {
	Fasthttp *fasthttp.RequestCtx
	// contains filtered or unexported fields
}

func (*Ctx) Next

func (ctx *Ctx) Next()

func (*Ctx) Params

func (ctx *Ctx) Params(key string) string

func (*Ctx) SendString

func (ctx *Ctx) SendString(body string)

func (*Ctx) Status

func (ctx *Ctx) Status(status int) *Ctx

func (*Ctx) Write

func (ctx *Ctx) Write(bodies ...string) *Ctx

type Group

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

func (*Group) Delete

func (g *Group) Delete(path string, handlers ...Handler)

func (*Group) Get

func (g *Group) Get(path string, handlers ...Handler)

func (*Group) Group

func (g *Group) Group(prefix string, handlers ...Handler) *Group

func (*Group) Post

func (g *Group) Post(path string, handlers ...Handler)

func (*Group) Put

func (g *Group) Put(path string, handlers ...Handler)

type Handler

type Handler = func(*Ctx)

type Seni

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

func New

func New() *Seni

func (*Seni) Delete

func (s *Seni) Delete(path string, handlers ...Handler)

func (*Seni) Get

func (s *Seni) Get(path string, handlers ...Handler)

func (*Seni) Group

func (s *Seni) Group(prefix string, handlers ...Handler) *Group

func (*Seni) Listen

func (s *Seni) Listen(address string) error

func (*Seni) Post

func (s *Seni) Post(path string, handlers ...Handler)

func (*Seni) Put

func (s *Seni) Put(path string, handlers ...Handler)

func (*Seni) Shutdown

func (s *Seni) Shutdown() error

func (*Seni) Test

func (s *Seni) Test(req *http.Request) (*http.Response, error)

Test creates a readWriter and calls ServeConn on local servver

func (*Seni) Use

func (s *Seni) Use(handlers ...Handler)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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