You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're excited to announce Encore now supports three of the most highly requested features: Middleware, Validation support, and Dependency Injection! Each one is large enough to warrant its own release but here's a three-for-one!
This means you can now:
Define service-specific or global middleware to implement cross-cutting concerns spanning several endpoints
Automatically validate incoming requests before invoking handlers
Simplify testing of Encore APIs and services
Hook into the service initialization and graceful shutdown process for custom logic
🥐 Run encore version update to grab the latest version, or read on for more information.
Encore Middleware
Middleware has been one of the most highly requested Encore features, and it's finally here! Unlike typical Go HTTP middleware, Encore's middleware operates on fully unmarshalled types which enables some incredible workflows. Here's how you define a middleware:
You can now define Encore APIs as methods on a Service Struct, which allows you to use dependency injection for easier testing of your Encore API endpoints. It introduces the new //encore:service directive that you can use to define a struct type as a Service Struct. It looks like this:
//encore:servicetypeServicestruct { /* dependencies go here */ }
//encore:api publicfunc (s*Service) MyAPI(ctx context.Context) error { /* ... */ }
The new Service Struct approach also comes with several other features, like service initialization and graceful shutdown hooks!
Read the docs on Service Structs and Dependency Injection for more information.
Bug fixes and other improvements
Fixed a case where the runtime was not fully initialized for test-only packages using sqldb.Named (compiler: fix runtime init #335)
We rely on the community to improve Encore, and we're overwhelmed by your support and encouragement. Thanks to @Willyham, @melkstam, @bjaanes, @Minivera, @davidmytton, @maxd and others for your feedback and contributions!
Join the most pioneering developer community
Developers building with Encore are forward-thinkers working on exciting and innovative products. Join the conversation on Slack to see what's going on, learn from others, and share what you're working on.
What's next
Over the coming weeks we'll be adding support for configuration, Azure Pub/Sub, caching, and more. Vote on your favorite feature on the roadmap!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We're excited to announce Encore now supports three of the most highly requested features: Middleware, Validation support, and Dependency Injection! Each one is large enough to warrant its own release but here's a three-for-one!
This means you can now:
🥐 Run encore version update to grab the latest version, or read on for more information.
Encore Middleware
Middleware has been one of the most highly requested Encore features, and it's finally here! Unlike typical Go HTTP middleware, Encore's middleware operates on fully unmarshalled types which enables some incredible workflows. Here's how you define a middleware:
See the middleware docs for more information!
Validation support
Encore now supports request validation out of the box! To use it, simplify define a
Validate() error
method on your request types. For example:See the validation docs for more information!
Dependency Injection
You can now define Encore APIs as methods on a Service Struct, which allows you to use dependency injection for easier testing of your Encore API endpoints. It introduces the new
//encore:service
directive that you can use to define a struct type as a Service Struct. It looks like this:The new Service Struct approach also comes with several other features, like service initialization and graceful shutdown hooks!
Read the docs on Service Structs and
Dependency Injection for more information.
Bug fixes and other improvements
sqldb.Named
(compiler: fix runtime init #335)Thanks to our contributors
We rely on the community to improve Encore, and we're overwhelmed by your support and encouragement. Thanks to @Willyham, @melkstam, @bjaanes, @Minivera, @davidmytton, @maxd and others for your feedback and contributions!
Join the most pioneering developer community
Developers building with Encore are forward-thinkers working on exciting and innovative products. Join the conversation on Slack to see what's going on, learn from others, and share what you're working on.
What's next
Over the coming weeks we'll be adding support for configuration, Azure Pub/Sub, caching, and more. Vote on your favorite feature on the roadmap!
If you like what we're up to, why not star Encore here on GitHub?
As always, if you have questions or feedback, tell us on Slack or just reply to this email.
We're excited to hear your feedback! ❤️
Catch you in the cloud,
The Encore Team
This discussion was created from the release Middleware, Validation, Dependency Injection, oh my!.
Beta Was this translation helpful? Give feedback.
All reactions