Swiftpack.co - Package - nodes-vapor/meta


Swift Version Vapor Version Circle CI codebeat badge codecov Readme Score GitHub license

This package enforces clients to send a specific header in all requests:


This header can look like this android;production;1.2.3;4.4;Samsung S7

  • platform
  • environment
  • app version
  • device os
  • device

For web platform only platform and environment is required, since the rest can be found in User-Agent.

Why not just use User-Agent?

  • User-Agent is missing some of these details
  • User-Agent can be hard to extend/override
  • Default User-Agent in iOS & Android can be their client (OkHttp, Alamofire etc).

📦 Installation

Update your Package.swift file.

.Package(url: "https://github.com/nodes-vapor/meta", majorVersion: 2)

Create config meta.json:

    "header": "N-Meta",
    "platforms": [
    "environments": [
    "exceptPaths": [
    "requiredEnvironments": [

Getting started 🚀

import class Meta.Middleware

Add middleware directly to your API groups (e.g. in Droplet+Setup.swift):

let metaMiddleware = try Meta.Middleware(config: self.config)
self.group(middleware: [metaMiddleware]) { metaRoutes in
    // ...

or add the middleware globally (e.g. in Config+Setup.swift) which will add it to all routes:

addConfigurable(middleware: Meta.Middleware.init, name: "meta")

Don't forget to add the middleware to your droplet.json config as well.

🏆 Credits

This package is developed and maintained by the Vapor team at Nodes. The package owner for this project is John.

📄 License

This package is open-sourced software licensed under the MIT license


Stars: 9
Help us keep the lights on



2.0.0 - Aug 23, 2017


  • Refactored some parts a bit to make the responsibility of some types more clear
  • Made it possible to properly add this as a middleware in Vapor 2 (sorry for not noticing this before now)

1.0.0 - May 18, 2017

  • Vapor 2 released 🎉

1.0.0-beta1 - Apr 28, 2017

  • Updated for Vapor 2

0.2.1 - Jan 5, 2017

  • exceptPaths now have * support

0.2.0 - Nov 17, 2016

  • Refactor