Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
HAL Browser is a tool built from the creator of the HAL Specification. There are a few tweaks that are made to integrate seamlessly with Spring Boot
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
All right, so for an example of something
that's using that metadata that we
0:00
just saw, let's take a look at
the HAL browser which again stands for
0:04
hypermedia application language.
0:09
Now the HAL browser requires
an extra dependency, but
0:12
I think you'll find it worthwhile
in your exploration phase.
0:16
So let's open up build.gradle.
0:18
And let's add this dependency.
0:21
So we'll say,
compile org.springframework.data.
0:23
We'll do spring-data-rest-hal-browser.
0:29
Not to be confused with that.
0:37
Open the pod bay door cell.
0:39
Okay, so we're gonna go over and
0:42
refresh our gradle.
0:47
Awesome, and
then let's restart the server.
0:50
Boom.
0:54
And now if we go just to the root of
our web page, what's gonna happen is,
1:00
we're going to see a brand new browser.
1:05
Now, this is super cool.
1:08
So, what this allows us to do is,
it's exploring those links, right?
1:11
So, those underscore links that we were
seeing before, this is what it's showing.
1:16
And it's letting us just go ahead and
navigate using HAL.
1:18
So let's go ahead and let's look at,
so see here reviews and
1:22
reviews are over here in courses and
courses over here.
1:25
So if we go ahead and
we do a get here, it will go ahead and
1:28
help us specify what we wanna do.
1:31
So we can say page 2 of courses and
we want the page list to be 10 and
1:34
you'll see that it's showing
us what the URI is gonna do.
1:38
If you click Follow URI,
it will build that actual page up here.
1:41
So here it is.
1:45
Here's the response body and
down here are the embedded courses.
1:47
And if you go and you can click,
you can open one of these up and
1:50
you can go and
look at the reviews for that.
1:53
Let me look at the first review here and
got a 3 and they wanted more spring and
1:56
you can just click around it all, right?
1:59
So if we go ahead,
let's go back to the entry point here.
2:03
Let's go to the front.
2:05
And again the links that
were provided here.
2:07
So we were clicking get before
to walk through this but
2:11
we can also do non get requests ,right.
2:14
So let's go ahead, let's add 1.
2:16
Let's add a new thing here.
2:17
So we'll perform a non-GET request.
2:19
And look at this,
it's using what we did, right?
2:22
So we're creating a collection
of online courses.
2:25
Here is the title,
2:28
here's the name of course, so it's using
that meta data that we just put in.
2:28
And it's automatically labeling the fields
to be more descriptive for what it is.
2:31
Pretty slick right, so let's go ahead
let's do Java objects a look right there.
2:36
And we will do library/java-objects.
2:42
And we're gonna do a post and it is too
small on this page to click unfortunately.
2:46
Or let me see if I can,
there we go, Make Request.
2:55
Boom and it gave us a 201 created.
3:01
So my favorite thing about this
tool is that you can use it
3:04
to expose clients writing
software to your API.
3:08
And they can learn how things work and
what they need to do to get things up and
3:10
running to use your API.
3:13
I'm definitely gonna shoot
this over to our team, right?
3:15
This is awesome.
3:18
So these tools, right,
the postman and the HAL browser.
3:19
There are good tools to use to
verify that you have things working.
3:22
And remember thus far, the only thing we
really need to test is the spot check that
3:25
we got things working like
we think they should behave.
3:30
We don't need to write any tests for any
of this functionality because the spring
3:33
data rest framework has
its own set of tests.
3:38
And just like the functionality
wasn't our responsibility to write,
3:41
testing that functionality isn't
our responsibility either.
3:46
So I'm glad you got a chance to
check out a few of these tools.
3:49
Check the teachers notes for more.
3:51
Now that we have a couple
easy ways of viewing and
3:52
setting headers,
let's go view a couple of features.
3:54
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up