https://github.com/hongyukeji/goravel-static
https://github.com/hongyukeji/goravel-static
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hongyukeji/goravel-static
- Owner: hongyukeji
- Created: 2024-06-13T16:29:00.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-06-13T17:35:35.000Z (about 1 year ago)
- Last Synced: 2025-01-03T16:34:59.894Z (6 months ago)
- Language: Go
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```2. 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
}
}
```3. Publish Configuration
```
go run . artisan vendor:publish --package=github.com/hongyukeji/goravel-static
```4. Testing
```
访问格式:[你的应用网址]/[public目录下的文件名]
例如:http://127.0.0.1:3000/logo.png
```The console will print `file`.