air

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

Air

A fast web framework for Go.

CI GitHub repo size Lines of code

Air is an easy-to-use, simple web framework for Go.

Usage example

Basic web server
app := air.New()
app.Get("/", func(c *air.Context) {
    ctx.String(200, "Hello World")
})
app.Listen(":8000")
Middlewares
app := air.New()
app.Use(func(c *air.Context) {
    fmt.Println(c.Method)
})
Router group
app := air.New()
user := app.Group("/user")
{
    user.Get("/", func(c *air.Context) {
        c.String(200, "Hello World")
    })
}

Meta

IceCafeCup – icecafecup@proton.me

Distributed under the Apache-2.0 license. See LICENSE for more information.

Contributing

  1. Fork it (https://github.com/icecafecup/air/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Air

type Air struct {
	*RouterGroup
	// contains filtered or unexported fields
}

Air service.

func New

func New() *Air

Create a server.

func (*Air) Listen

func (a *Air) Listen(addr string) error

Listen and serve.

type Context

type Context struct {
	Writer  http.ResponseWriter
	Request *http.Request

	Method string
	Path   string
	// contains filtered or unexported fields
}

func NewContext

func NewContext(w http.ResponseWriter, r *http.Request) *Context

func (*Context) Bytes

func (c *Context) Bytes(code int, data []byte)

func (*Context) Error

func (c *Context) Error(code int, err error)

func (*Context) GetHeader

func (c *Context) GetHeader(key string) string

func (*Context) GetParam

func (c *Context) GetParam(key string) string

func (*Context) HTML added in v0.2.0

func (c *Context) HTML(code int, v string)

func (*Context) JSON

func (c *Context) JSON(code int, obj any)

func (*Context) Next

func (c *Context) Next()

func (*Context) Query

func (c *Context) Query(key string) string

func (*Context) SetHeader

func (c *Context) SetHeader(key, value string)

func (*Context) String

func (c *Context) String(code int, format string, v ...any)

type Handler

type Handler func(*Context)

Handler is for processing the request.

type Map

type Map = map[string]any

type RouterGroup

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

Router group.

func (*RouterGroup) Delete

func (g *RouterGroup) Delete(path string, h Handler)

Add DELETE handler.

func (*RouterGroup) Get

func (g *RouterGroup) Get(path string, h Handler)

Add GET handler.

func (*RouterGroup) Group

func (g *RouterGroup) Group(path string) *RouterGroup

Create a router group.

func (*RouterGroup) Patch

func (g *RouterGroup) Patch(path string, h Handler)

Add PATCH handler.

func (*RouterGroup) Post

func (g *RouterGroup) Post(path string, h Handler)

Add POST handler.

func (*RouterGroup) Put

func (g *RouterGroup) Put(path string, h Handler)

Add PUT handler.

func (*RouterGroup) Use

func (g *RouterGroup) Use(h ...Handler)

Add middlewares.

Jump to

Keyboard shortcuts

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