ginrest

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

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

Go to latest
Published: Nov 2, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

README

ginrest

ginrest is simple, helpful , customizable, realize your idea with it!

Limitation

golang version >= 1.11

Installation

go get
go get gitee.com/Ivy1996-encode/ginrest
go mod
require gitee.com/Ivy1996-encode/ginrest 

Example

one struct with six routers!

package main

import "gitee.com/Ivy1996-encode/ginrest"

type User struct {
	ginrest.ModelViewSet
}

func main() {
	server := ginrest.Default()

	router := ginrest.DefaultRouter(server)

	router.Register("/user", new(User))

	server.Run()
}
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /user/                    --> gitee.com/Ivy1996-encode/ginrest/ghttp/handlers.RegisterHandlerErrorMiddleware.func1 (3 handlers)
[GIN-debug] GET    /user/:id/                --> gitee.com/Ivy1996-encode/ginrest/ghttp/handlers.RegisterHandlerErrorMiddleware.func1 (3 handlers)
[GIN-debug] POST   /user/                    --> gitee.com/Ivy1996-encode/ginrest/ghttp/handlers.RegisterHandlerErrorMiddleware.func1 (3 handlers)
[GIN-debug] PUT    /user/:id/                --> gitee.com/Ivy1996-encode/ginrest/ghttp/handlers.RegisterHandlerErrorMiddleware.func1 (3 handlers)
[GIN-debug] PATCH  /user/:id/                --> gitee.com/Ivy1996-encode/ginrest/ghttp/handlers.RegisterHandlerErrorMiddleware.func1 (3 handlers)
[GIN-debug] DELETE /user/:id/                --> gitee.com/Ivy1996-encode/ginrest/ghttp/handlers.RegisterHandlerErrorMiddleware.func1 (3 handlers)
[GIN-debug] Listening and serving HTTP on :8000

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Default

func Default() *gin.Engine

Shortcut for gin.Default

func DefaultRouter

func DefaultRouter(engine *gin.Engine, middleware ...gin.HandlerFunc) *grouter.DefaultRouter

Shortcut for grouter.NewDefaultRouter

func MakeStructAsHandlerFunc

func MakeStructAsHandlerFunc(view interface{}) gin.HandlerFunc

Shortcut for dispatch.MakeStructAsHandlerFunc

func NewRouter

func NewRouter(engine *gin.Engine, middleware ...gin.HandlerFunc) *grouter.Router

Shortcut for grouter.NewRouter

Types

type CreateView

type CreateView struct{}

func (*CreateView) Create

func (*CreateView) Create(context *gin.Context)

type DestroyView

type DestroyView struct{}

func (*DestroyView) Destroy

func (m *DestroyView) Destroy(context *gin.Context)

type ListView

type ListView struct{}

func (*ListView) List

func (*ListView) List(context *gin.Context)

func (*ListView) Retrieve

func (*ListView) Retrieve(context *gin.Context)

type PartialUpdateView

type PartialUpdateView struct{}

func (*PartialUpdateView) PartialUpdate

func (*PartialUpdateView) PartialUpdate(context *gin.Context)

type ReadOnlyViewSet

type ReadOnlyViewSet struct {
	ListView
	RetrieveView
}

type RetrieveView

type RetrieveView struct{}

type UpdateView

type UpdateView struct{}

func (*UpdateView) Update

func (*UpdateView) Update(context *gin.Context)

type UpdateViewSet

type UpdateViewSet struct {
	UpdateView
	PartialUpdateView
}

Directories

Path Synopsis
contrib

Jump to

Keyboard shortcuts

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