1
0
mirror of https://github.com/Luzifer/gziphttp.git synced 2024-09-16 15:08:31 +00:00
Very simple HTTP server for serving static files with ability for gzip compression if supported by the client
Go to file
2020-09-03 15:26:46 +02:00
.gitignore Initial version 2019-06-02 01:12:35 +02:00
.repo-runner.yaml Add more archs for build 2020-09-03 15:25:55 +02:00
go.mod Initial version 2019-06-02 01:12:35 +02:00
go.sum Add checksum for windows build 2020-09-03 11:06:36 +02:00
History.md prepare release v0.1.1 2020-09-03 15:26:46 +02:00
LICENSE Initial version 2019-06-02 01:12:35 +02:00
main.go Properly set up handler, add logging 2019-10-19 20:30:39 +02:00
Makefile Add automated build 2020-09-03 11:09:15 +02:00
README.md Add help 2019-06-02 01:24:21 +02:00

Go Report Card

Luzifer / gziphttp

Very simple HTTP server for serving static files with ability for gzip compression if supported by the client.

Usage

# gziphttp -h
Usage of gziphttp:
      --listen string      Port/IP to listen on (default ":3000")
      --log-level string   Log level (debug, info, warn, error, fatal) (default "info")
  -d, --serve-dir string   Directory to serve files from (default ".")
      --version            Prints current version and exits

Here is an example usage inside a Docker container containing (quite large) compiled JavaScript files:

FROM golang:alpine as go

RUN set -ex \
 && apk add git \
 && go get -v github.com/Luzifer/gziphttp


FROM node:alpine as node

COPY . /src
WORKDIR /src

RUN set -ex \
 && npm ci \
 && npm run build


FROM alpine:latest

COPY --from=go    /go/bin/gziphttp  /usr/local/bin/
COPY --from=node  /src/dist         /usr/local/share/webtotp

EXPOSE 3000/tcp
CMD ["gziphttp", "-d", "/usr/local/share/webtotp"]

In this case gziphttp serves compressed files to most (all modern) browsers which ensures the download size of the JavaScript files does not hurt as much as it would without gzip compression.