Skip to content

voronianski/vapor-favicon-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vapor Favicon Middleware

Swift Platforms Package Managers

Favicon serving middleware for Vapor.

Installation

Via Swift Package Manager:

.Package(url: "https://github.com/voronianski/vapor-favicon-middleware.git", majorVersion: 1)

Why?

Favicon is a visual cue that client software, like browsers, use to identify a site. So why to use this module?

  • it caches the icon in memory to improve performance by skipping disk access
  • it will serve with the most compatible Content-Type

Usage

import Vapor
import VaporFaviconMiddleware

let drop = Droplet()

// path to favicon image in workDir...
let faviconPath = drop.workDir.appending("/Public/assets/favicon.png")
drop.middleware.append(FaviconMiddleware(faviconPath))

// ...or overwrite default cache-control max-age directive in ms (defaulting to 1 day)
let maxAge = 1000 * 60 * 60 * 24 * 365 // 1 month
drop.middleware.append(FaviconMiddleware(faviconPath, maxAge: maxAge))

MIT Licensed

About

Favicon serving middleware for Vapor applications.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages