gee

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: MIT Imports: 9 Imported by: 0

README

logo

Gee API Framework

Gee API Framework encapsulates the net/http framework, making it easier and faster for us to write backend APIs

Gee has the following characteristics

  • Fast
  • Zero allocation router
  • Middleware support
  • Routes grouping
  • Extendable

Get Started

Prerequisites
  • Go: any one of the three latest major releases (we test it with these).
Getting Gee
import "github.com/gitlayzer/gee_api_framework"

to your code, and then go [build|run|test] will automatically fetch the necessary dependencies.

Otherwise, run the following Go command to install the gin package:

$ go get -u github.com/gitlayzer/gee_api_framework
Running Gee

First you need to import Gee package for using Gee, one simplest example likes the follow main.go:

package main

import gee "github.com/gitlayzer/gee_api_framework"

func main() {
	r := gee.Default()

	r.GET("/", func(c *gee.Context) {
		c.JSON(200, gee.H{
			"message": "Hello Gee",
		})
	})

	_ = r.Run(":8888")
}

And use the Go command to run the demo:

❯ go run .\main.go
2024/03/24 17:23:12 [Gee]  GET - /

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDebug

func IsDebug() bool

Types

type Context

type Context struct {
	Writer     http.ResponseWriter
	Request    *http.Request
	Path       string
	Method     string
	Params     map[string]string
	StatusCode int
	// contains filtered or unexported fields
}

func NewContext

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

func (*Context) Abort added in v0.0.2

func (c *Context) Abort()

func (*Context) AbortWithStatus added in v0.0.2

func (c *Context) AbortWithStatus(code int)

func (*Context) Data

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

func (*Context) DeleteHeader added in v0.0.2

func (c *Context) DeleteHeader(key string)

func (*Context) Fail

func (c *Context) Fail(code int, err string)

func (*Context) GetHeader added in v0.0.2

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

func (*Context) HTML

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

func (*Context) JSON

func (c *Context) JSON(code int, obj interface{})

func (*Context) Next

func (c *Context) Next()

func (*Context) Param

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

func (*Context) PostForm

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

func (*Context) Query

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

func (*Context) SetHeader

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

func (*Context) Status

func (c *Context) Status(code int)

func (*Context) String

func (c *Context) String(code int, format string, values ...interface{})

type Engine

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

func Default

func Default() *Engine

func New

func New() *Engine

func (*Engine) Run

func (engine *Engine) Run(addr string) (err error)

func (*Engine) ServeHTTP

func (engine *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)

type H

type H map[string]interface{}

type HandlerFunc

type HandlerFunc func(ctx *Context)

func Logger

func Logger() HandlerFunc

func Recovery

func Recovery() HandlerFunc

func Server

func Server() HandlerFunc

type RouterGroup

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

func (*RouterGroup) Any added in v0.0.2

func (group *RouterGroup) Any(pattern string, handler HandlerFunc)

func (*RouterGroup) DELETE

func (group *RouterGroup) DELETE(pattern string, handler HandlerFunc)

func (*RouterGroup) GET

func (group *RouterGroup) GET(pattern string, handler HandlerFunc)

func (*RouterGroup) Group

func (group *RouterGroup) Group(prefix string) *RouterGroup

func (*RouterGroup) HEAD

func (group *RouterGroup) HEAD(pattern string, handler HandlerFunc)

func (*RouterGroup) OPTIONS

func (group *RouterGroup) OPTIONS(pattern string, handler HandlerFunc)

func (*RouterGroup) PATCH

func (group *RouterGroup) PATCH(pattern string, handler HandlerFunc)

func (*RouterGroup) POST

func (group *RouterGroup) POST(pattern string, handler HandlerFunc)

func (*RouterGroup) PUT

func (group *RouterGroup) PUT(pattern string, handler HandlerFunc)

func (*RouterGroup) Use

func (group *RouterGroup) Use(middlewares ...HandlerFunc)

Jump to

Keyboard shortcuts

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