Skip to content

hongyukeji/goravel-static

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Goravel Static

An Static For A Goravel Extend Package

将public目录下的文件挂载至应用根路径

Directory Structure

This is a directory standard, but you can change it if you like.

Directory Action
config Store the config files
middleware Store the middleware files

Install

  1. Add package
go get -u github.com/hongyukeji/goravel-static
  1. Use

2.1注册服务和2.2中间件任选一种即可

  • 2.1:Register service provider
// config/app.go
static "github.com/hongyukeji/goravel-static"

"providers": []foundation.ServiceProvider{
    ...
    &static.ServiceProvider{},
}
  • 2.2:Use middleware
// app/http/kernel.go
import staticmiddleware "github.com/hongyukeji/goravel-static/middleware"

func (kernel Kernel) Middleware() []http.Middleware {
	return []http.Middleware{
		staticmiddleware.Static(), // add static middleware
	}
}
  1. Publish Configuration
go run . artisan vendor:publish --package=github.com/hongyukeji/goravel-static
  1. Testing
访问格式:[你的应用网址]/[public目录下的文件名]
例如:http://127.0.0.1:3000/logo.png

The console will print file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages