github.com/scottcagno/storage@v1.8.0/pkg/web/content.go (about)

     1  package web
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  )
     7  
     8  var (
     9  	ContentTypeTextHTML       = "text/html"
    10  	ContentTypeTextPlain      = "text/plain"
    11  	ContentTypeTextCSS        = "text/css"
    12  	ContentTypeTextCSV        = "text/csv"
    13  	ContentTypeTextJavaScript = "text/javascript"
    14  
    15  	ContentTypeApplicationXML         = "application/xml"
    16  	ContentTypeApplicationZip         = "application/zip"
    17  	ContentTypeApplicationPDF         = "application/pdf"
    18  	ContentTypeApplicationJSON        = "application/json"
    19  	ContentTypeApplicationJavaScript  = "application/javascript"
    20  	ContentTypeApplicationOctetStream = "application/octet-stream"
    21  
    22  	ContentTypeImageAPNG = "image/apng"
    23  	ContentTypeImageGIF  = "image/gif"
    24  	ContentTypeImageJPEG = "image/jpeg"
    25  	ContentTypeImagePNG  = "image/png"
    26  	ContentTypeSVGXML    = "image/svg+xml"
    27  	ContentTypeWebP      = "image/webp"
    28  
    29  	ContentTypeMultiPartFormData = "multipart/form-data"
    30  )
    31  
    32  func ContentType(w http.ResponseWriter, ct string) {
    33  	w.Header().Set("Content-Type", fmt.Sprintf("%s; charset=utf-8", ct))
    34  }