webp_server_go/README.md
Benny 08c333f3cd
Fiber v2, code format, typo,test case, go 1.15 and more (#54)
* upgrade to fiber v2

* code format

* remove redundant variables
* remove useless exportable variables/functions

* go mod replace

use our own mirror now.

* add test case for converter, use deferInit to make test more simple

* remove useless file and fix typo

* Makefile change
* upgrade to go 1.15
* remove wrong go test comments

* complete test case, coverage, coverage badge

* Fix version typo

* config struct fix

* add banner, show version, add server header, remove fiber startup message

Co-authored-by: n0vad3v <n0vad3v@riseup.net>
2020-11-21 13:26:03 +08:00

78 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p align="center">
<img src="./pics/webp_server.png"/>
</p>
<img src="https://api.travis-ci.org/webp-sh/webp_server_go.svg?branch=master"/>
[![codecov](https://codecov.io/gh/webp-sh/webp_server_go/branch/master/graph/badge.svg?token=VR3BMZME65)](https://codecov.io/gh/webp-sh/webp_server_go)
[Documentation](https://docs.webp.sh/) | [Website](https://webp.sh/)
This is a Server based on Golang, which allows you to serve WebP images on the fly.
It will convert `jpg,jpeg,png` files by default, this can be customized by editing the `config.json`..
* currently supported image format: JPEG, PNG, BMP, GIF(static image for now)
> e.g When you visit `https://your.website/pics/tsuki.jpg`it will serve as `image/webp` format without changing the URL.
>
> For Safari and Opera users, the original image will be used.
## Simple Usage Steps
### 1. Download or build the binary
Download the `webp-server` from [release](https://github.com/webp-sh/webp_server_go/releases) page.
### 2. Dump config file
```
./webp-server -dump-config > config.json
```
The default `config.json` may look like this.
```json
{
"HOST": "127.0.0.1",
"PORT": "3333",
"QUALITY": "80",
"IMG_PATH": "/path/to/pics",
"EXHAUST_PATH": "/path/to/exhaust",
"ALLOWED_TYPES": ["jpg","png","jpeg"]
}
```
#### Config Example
In the following example, the image path and website URL.
| Image Path | Website Path |
| ------------------------------------- | ------------------------------------ |
| `/var/www/img.webp.sh/path/tsuki.jpg` | `https://img.webp.sh/path/tsuki.jpg` |
The `config.json` should be like:
| IMG_PATH |
| ---------------------- |
| `/var/www/img.webp.sh` |
`EXHAUST_PATH` is cache folder for output `webp` images, with `EXHAUST_PATH` set to `/var/cache/webp`
in the example above, your `webp` image will be saved at `/var/cache/webp/pics/tsuki.jpg.1582558990.webp`.
### 3. Run
```
./webp-server --config=/path/to/config.json
```
### 4. Nginx proxy_pass
Let Nginx to `proxy_pass http://localhost:3333/;`, and your webp-server is on-the-fly.
## Advanced Usage
For supervisor, Docker sections, please read our documentation at [https://docs.webp.sh/](https://docs.webp.sh/)
## License
WebP Server is under the GPLv3. See the [LICENSE](./LICENSE) file for details.