Skip to content

johejo/azblobproxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

azblobproxy

Azure Blob Storage Proxy

GitHub Actions GoDoc

Example

package main

import (
	"log"
	"net/http"
	"os"

	"github.com/johejo/azblobproxy"
)

// An example as a proxy for single page application.
func main() {
	accountName := os.Getenv("AZURE_BLOB_STORAGE_ACCOUNT_NAME")
	accountKey := os.Getenv("AZURE_BLOB_STORAGE_ACCOUNT_KEY")
	containerName := os.Getenv("AZURE_BLOB_STORAGE_CONTAINER_NAME")

	handler := azblobproxy.SimpleHandler(accountName, accountKey, containerName)
	handler.IndexDocumentName = "index.html"
	handler.NotFoundDocumentPath = "index.html"

	logger := func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			log.Println(r.Method, r.URL)
			next.ServeHTTP(w, r)
		})
	}

	mux := http.NewServeMux()
	mux.Handle("/", logger(handler))
	log.Println(http.ListenAndServe("localhost:8080", mux))
}

Releases

No releases published

Packages

No packages published

Languages