gziphttp

command module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

README

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.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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