knife4go

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 8 Imported by: 0

README

knife4go

simply Assembled knife4j + gin-swagger, it means an enhanced version of gin-swagger with nice UI.

work well on go1.18+

go get

go get github.com/go-webtools/knife4go

usage

Based on the usage of gin-swagger, add sth as follows:

import (
	knife4goGin "github.com/go-webtools/knife4go/gin"
	knife4goFiles "github.com/go-webtools/knife4go"
    ...
	swaggerFiles "github.com/swaggo/files"     // swagger embed files
	ginSwagger "github.com/swaggo/gin-swagger" // gin-swagger middleware
)

func InitRouters() *gin.Engine {
    	router := gin.Default()
	// swagger base router
	router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
	// knife4go: beautify swagger-ui
	router.GET("/knife4go/*any", knife4goGin.WrapHandler(knife4goFiles.Handler))
    ...
}

Disclaimer

Public welfare projects.
The disclaimer asserts that the individual won't be held responsible for any. LICENSE

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CTX is a context for webdav vfs
	CTX = context.Background()

	// FS is a virtual memory file system
	FS = webdav.NewMemFS()

	// Handler is used to server files through a http handler
	Handler *webdav.Handler

	// HTTP is the http file system
	HTTP http.FileSystem = new(HTTPFS)
)

Functions

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile is adapTed from ioutil

func WalkDirs

func WalkDirs(name string, includeDirsInList bool, files ...string) ([]string, error)

WalkDirs looks for files in the given dir and returns a list of files in it usage for all files in the b0x: WalkDirs("", false)

func WriteFile

func WriteFile(filename string, data []byte, perm os.FileMode) error

WriteFile is adapTed from ioutil

Types

type HTTPFS

type HTTPFS struct {
	// Prefix allows to limit the path of all requests. F.e. a prefix "css" would allow only calls to /css/*
	Prefix string
}

HTTPFS implements http.FileSystem

func (*HTTPFS) Open

func (hfs *HTTPFS) Open(path string) (http.File, error)

Open a file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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