Hecklers in Development
Code, coffee, & camaraderie. Collection, unordered. ;)

Just a quick tip for the Spring fans out there…

 

I was leading a workshop yesterday and this question arose: Is it possible to filter requests by header content using Spring’s various request mapping (@RequestMapping, @GetMapping, @PostMapping, et al) annotations?

 

Not only is it possible, it’s easy, and the implementation is concise & clean! Let’s take a look.

 

The code

Here is a simple example that filters based upon the content-type of the header:

 

 

To test this, simply visit the Spring Initializr, create a simple Spring Boot app with a single dependency (Web), download & unzip it, and add the code above using your favorite IDE. Then build & run it (of course)! 😉

 

The output

Using httpie (which is quickly becoming my favorite CLI HTTP client), we can verify our results:

 

Request content type of text/plain

 

Request content type of application/json

 

NOTE: The above examples use httpie “shorthand”, which assumes localhost when the base URL is omitted.

 

That’s all for now, but stay tuned (or follow me on Twitter) for more quick (or more lengthy) Spring tips!

 

Cheers,
Mark

 

Click here for additional information

 

Share

Related Posts:


Tags: , , , , , , , ,

At JavaOne last week, several people asked me how my work at Pivotal was going, and it occurred to me: I had been so busy diving into all the new toys that I hadn’t written anything about it! This is a first step toward remedying that.  🙂

 

At the risk of this post sounding like a short commercial, I’m deeply impressed with the consistency of vision and the depth and breadth of capabilities Pivotal offers innovative organizations and developers. The various Spring offerings solve real problems, and they solve them in ways that are “developer first”…ways that make sense not just conceptually, but also when pounding out code in an IDE (or vi/emacs, if you prefer). You hear a lot about an “opinionated” approach, and that could be chafing if there weren’t such flexibility to do it it your way anytime needed/desired; but the goal is always the same:

 

Offer a way to get things done cleanly and easily by following a prescribed (opinionated) approach…

…but get out of the way quickly when another approach is warranted/desired.

 

Best of both worlds.

 

With regard to Pivotal Cloud Foundry…I once heard it described as the “travel adapter” of cloud services, and that explanation is brilliant. In short, Pivotal Cloud Foundry (PCF):

  • Works with a variety of underlying infrastructures (VMware, OpenStack, Amazon, Azure, Google Cloud)
  • Runs on-premises or public
  • Provides a single, elegant API for developers, regardless of infrastructure
  • Provides a single, elegant API for developers, regardless of siting (on-premises or public cloud)
  • Provides a true Cloud Native platform: drag, drop, run

If you’ve used other cloud platforms (and not yet used Pivotal Cloud Foundry), you’re probably reading and re-reading that list with some combination of skepticism and guarded envy. Don’t believe me; believe yourself: sign up for a free 60-day trial here and kick the tires. No better way to see the future than to create a small Spring Boot application (or bring your own) and deploy it to PCF. You’ll wonder why other vendors make it so difficult when it can be so straightforward.

 

In summary, I’m working on a great team in a great company with products from the future. What’s not to love? 😀

 

Cheers,
Mark

 

For everyone I met and re-met (!) at JavaOne, thank you for your friendship and commitment to this great community! Looking forward to our paths crossing again, and looking forward to meeting new “old friends” soon.

 

Please check back here (or follow me on Twitter: @MkHeck) for periodic ponderances, quick tips, and everything in between. Keep that code flowing!

 

Share

Related Posts:

  • Please check back for related posts!

pivotal:

  1. Of, relating to, or serving as a pivot.
  2. Being of vital or central importance; crucial.

As has been widely reported, last week I was among those at Oracle who were “let go” – a sanitized expression that is meant to diminish the indescribable impact of being fired due to circumstances far outside one’s knowledge or ability to influence. Details aren’t important, but suffice it to say that my teammates and I were…surprised. 🙂

 

The Java community is so much more than one company. It is many companies, organizations, not-for-profits, JUGs, individuals…so many who make it the vibrant, sharing community we all love. I’ve spoken with several, and I’ve had some wonderful conversations with organizations with a vision. This community is very much alive, and great ideas are flowing, with more on tap!

 

Pivotal

Which brings me to some exciting news! I’ll soon be joining the team at Pivotal. I won’t name names, as there are simply too many outstanding colleagues to mention without inadvertently leaving someone out. But you know them: they’re thinkers, innovators, and doers. Pivotal has some great tools in their toolbox, and I can’t wait to put every one of them to good use! I feel like a kid in a candy store. 🙂

 

I still have some good friends and colleagues within Oracle, and I respect them deeply for doing amazing things with Java and the community. They are awesome, and those individuals deserve your support. But this is a pivotal (you knew that pun was coming, didn’t you?!?!) moment for me, and I look forward to some pretty amazing things moving forward!

 

Whether you’re an old friend or new, or a soon-to-be one, if you happen to be at a conference where I am, please catch up with me and say “Hi”. I’m looking forward to it. 🙂

 

Onward & upward,
Mark

 

Follow me on Twitter (@MkHeck) for updates as the journey unfolds!

Share

Related Posts:

  • Please check back for related posts!

We’ve recently added the capability to send/receive secure, signed and/or encrypted emails.

Why?

Simply put, we have nothing to hide. To paraphrase a movie line, we aren’t even very exciting. 🙂 But just as we don’t put pictures of our underwear & sock drawers online for just anyone to see, we aren’t all that enthused about perfect strangers poring over our grocery lists, family emails, etc. I suspect most people aren’t.

How?

It’s pretty quick and easy to secure your email using PGP/GPG (Pretty Good Privacy and the Gnu Privacy Guard). Here are some links you can use to “get secure” in a matter of minutes on most platforms:

Mac

GPGTools, available here.

Windows

GPG4Win, available here.

GMail in Chrome

Mailvelope, available here and in the Chrome Store.

The Bottom Line

If you’ve never used PKI (Public Key Infrastructure) solutions before, you may want to read up on them a bit. The summary version, though, is that you have a private key that you keep (PRIVATE!) and a public key you publish for others to use when sending you mail. To email someone else, you either retrieve their public key from a central key server or simply copy/paste it from an email or website into your keychain, then address your email to them and choose to sign, encrypt, or both. That’s it.

 

If you’d like to send us a test email, please feel free to either download our public keys from the server or just go here to get them. Good luck, and all the best to you in a more secure future!

 

Share

Related Posts:


Tags: , , , , , , ,

Powered by Wordpress
Theme © 2005 - 2009 FrederikM.de, heavily modified by Mark Heckler
BlueMod is a modification of the blueblog_DE Theme by Oliver Wunder