github.com/IRelaxxx/servefiles/v3@v3.4.6/README.md (about)

     1  # servefiles
     2  
     3  [![GoDoc](https://img.shields.io/badge/api-Godoc-blue.svg)](https://pkg.go.dev/github.com/rickb777/servefiles)
     4  [![Build Status](https://travis-ci.org/rickb777/servefiles.svg?branch=master)](https://travis-ci.org/rickb777/servefiles/builds)
     5  [![Coverage Status](https://coveralls.io/repos/rickb777/servefiles/badge.svg?branch=master&service=github)](https://coveralls.io/github/rickb777/servefiles?branch=master)
     6  [![Go Report Card](https://goreportcard.com/badge/github.com/rickb777/servefiles)](https://goreportcard.com/report/github.com/rickb777/servefiles)
     7  [![Issues](https://img.shields.io/github/issues/rickb777/servefiles.svg)](https://github.com/rickb777/servefiles/issues)
     8  
     9  Serve static files from a Go http server, including performance-enhancing features.
    10  
    11   * Based on the standard net/http ServeFiles, with gzip/brotli and cache performance enhancements.
    12  
    13  Please see the [GoDoc](https://godoc.org/github.com/rickb777/servefiles) for more.
    14  
    15  ## Installation
    16  
    17      go get -u github.com/IRelaxxx/servefiles/v3
    18  
    19  ## MaxAge
    20  
    21  User agents can cache responses. This http server enables easy support for two such mechanisms:
    22  
    23   * Conditional requests (using `etags`) allow the response to be sent only when it has changed
    24   * MaxAge response headers allow the user agent to cache entities until some expiry time.
    25  
    26  Note that conditional requests (RFC7232) and MaxAge caching (RFC7234) can work together as required. Conditional requests still require network round trips, whereas caching removes all network round-trips until the entities reach their expiry time. 
    27  
    28  ## SPA support
    29  
    30  There is support for serving SPA webpage by using WithSPA() this serves index.html for all resources that do not have a file extension
    31  
    32  ## Gin Adapter
    33  
    34  Sub-package gin_adapter provides integration hooks into the [Gin web framework](github.com/gin-gonic/gin). This makes it easy for Gin code to use this asset handler also: see the example in the sub-package for more info.
    35  
    36  ## v3
    37  
    38  Version 3 brings Go module support. Also, `brotli` encoding is supported alongside `gzip` encoding. Brotli now has widespread implementation in most browsers. You can compress your textual assets (including Javascript, CSS, HTML, SVG etc) using Brotli and/or Gzip as part of your build pipeline, uploading both the original and compressed files to your production server's asset directories. Brotli compression takes longer than Gzip but produces more compact files. Compression is, of course, optional.
    39   
    40  ## Earlier versions
    41  
    42  Earlier versions do not support Go modules, nor `brotli` encoding, although `gzip` encoding is supported.
    43   
    44  ## Status
    45  
    46  This library has been in reliable production use for some time. Versioning follows the well-known semantic version pattern.
    47  
    48  ## Licence
    49  
    50  [MIT](LICENSE)