Merge pull request #32 from nodes-vapor/feature/update-ci Align test action
Merge pull request #32 from nodes-vapor/feature/update-ci
Align test action
This package enforces clients to send a specific header in all requests:
N-Meta: [PLATFORM];[ENVIRONMENT];[APP_VERSION];[DEVICE_OS];[DEVICE]
If you’re running an older version of Vapor then have a look here:
This header can look like this android;production;1.2.3;4.4;Samsung S7
android;production;1.2.3;4.4;Samsung S7
For web platform only platform and environment is required, since the rest can be found in User-Agent.
User-Agent
Why not just use User-Agent?
Update your Package.swift file.
Package.swift
... dependencies: [ ... .package(url: "https://github.com/nodes-vapor/n-meta.git", from: "4.0.0") ], targets: [ .target( name: "App", dependencies: [ ... .product(name: "NMeta", package: "n-meta"), ] ) ...
Configure NMeta as per your needs, for example:
app.nMeta = .init(exceptPath: ["/admin"])
Next, add the middleware directly to your routes (e.g. in routes.swift):
routes.swift
app.grouped(NMetaMiddleware()).get("hello") { req in "Hello, world!" }
or add the middleware globally (e.g. in configure.swift) which will add it to all routes:
configure.swift
app.middlewares.use(NMetaMiddleware())
This package is developed and maintained by the Vapor team at Nodes.
This package is open-sourced software licensed under the MIT license
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
N-Meta Ⓜ️
This package enforces clients to send a specific header in all requests:
If you’re running an older version of Vapor then have a look here:
This header can look like this
android;production;1.2.3;4.4;Samsung S7
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 detailsUser-Agent
can be hard to extend/overrideUser-Agent
in iOS & Android can be their client (OkHttp, Alamofire etc).📦 Installation
Update your
Package.swift
file.Getting started 🚀
Configure NMeta as per your needs, for example:
Next, add the middleware directly to your routes (e.g. in
routes.swift
):or add the middleware globally (e.g. in
configure.swift
) which will add it to all routes:🏆 Credits
This package is developed and maintained by the Vapor team at Nodes.
📄 License
This package is open-sourced software licensed under the MIT license