Categorygithub.com/vokinneberg/http-cache
modulepackage
1.0.1
Repository: https://github.com/vokinneberg/http-cache.git
Documentation: pkg.go.dev

# README

http-cache

Yet another useless caching middleware for Go.

Why?

First, this was part of the job test assessment. But I think that it shouldn't go to the trash bin and might be useful for someone. So, generally speaking - Just for fun. I got the job, BTW 😉

Getting Started

Installation

go get -u github.com/vokinneberg/http-cache

Usage

Generic Go middleware

    mux := http.NewServeMux()
    mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        w.Header().Set("Content-Type", "application/json")
        w.Write([]byte("{\"hello\": \"world\"}"))
    })

    handler := http_cache.NewDefault().Handler(mux)
    http.ListenAndServe(":8080", handler)

Negroni middleware

    mux := http.NewServeMux()

    mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        w.Header().Set("Content-Type", "application/json")
        w.Write([]byte("{\"hello\": \"world\"}"))
    })

    n := negroni.Classic()

    n.Use(http_cache.NewDefault())
    n.UseHandler(mux)
    n.Run(":8080")

Roadmap

  • Add Unit tests.
  • Add benchmarks - I really interested in how efficient this implementation is?
  • Make middleware RFC7234 complaint.
  • Add more data store adapters such as: Redis, memcached, DynamoDB, etc.

# Packages

No description provided by the author

# Functions

New creates a new instance of `httpcache` middleware.
NewDefault creates a new instance of `http-cache` middleware with default Options.
No description provided by the author

# Structs

A HttpCache is a caching middleware.
Options a configuration container for `httpcache` middleware.

# Interfaces

No description provided by the author