api

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Copyright (c) 2019 Eduard Urbach

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API type

func New

func New(cfg *config.Config) *API

New return new api

func (*API) Run

func (a *API) Run(ctx context.Context)

Run API server

type Context added in v1.3.2

type Context struct {
	Request *http.Request
	Writer  http.ResponseWriter
	Handler Handler
	Params  *Params
}

func (*Context) JSON added in v1.3.2

func (ctx *Context) JSON(code int, data any)

func (*Context) Param added in v1.3.2

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

type Group added in v1.3.2

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

func (*Group) GET added in v1.3.2

func (g *Group) GET(path string, handle Handler)

func (*Group) Handle added in v1.3.2

func (g *Group) Handle(method, path string, handle Handler)

func (*Group) POST added in v1.3.2

func (g *Group) POST(path string, handle Handler)

type Handler added in v1.3.2

type Handler func(ctx *Context)

type Json added in v1.3.2

type Json map[string]any

type Param added in v1.3.2

type Param struct {
	Key   string
	Value string
}

type Params added in v1.3.2

type Params []Param

type Router added in v1.3.2

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

func NewRouter added in v1.3.2

func NewRouter() *Router

func (*Router) GET added in v1.3.2

func (rt *Router) GET(path string, handle Handler)

func (*Router) Group added in v1.3.2

func (rt *Router) Group(rp string) *Group

func (*Router) Handle added in v1.3.2

func (rt *Router) Handle(method, path string, handle Handler)

func (*Router) POST added in v1.3.2

func (rt *Router) POST(path string, handle Handler)

func (*Router) ServeHTTP added in v1.3.2

func (rt *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Tree added in v1.3.2

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

Tree represents a radix tree.

func (*Tree) Add added in v1.3.2

func (tree *Tree) Add(path string, data dataType)

Add adds a new element to the tree.

func (*Tree) Lookup added in v1.3.2

func (tree *Tree) Lookup(ctx *Context)

Lookup finds the data for the request path and assigns it to ctx.Handler, if available.

Jump to

Keyboard shortcuts

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