Skip to content

Instantly share code, notes, and snippets.

View mkheck's full-sized avatar
💭
Coding, of course!

Mark Heckler mkheck

💭
Coding, of course!
View GitHub Profile
>> http :8080/test content-type:text/plain
HTTP/1.1 200
Content-Length: 27
Content-Type: text/plain;charset=UTF-8
Date: Thu, 08 Jun 2017 15:46:30 GMT
X-Application-Context: application
This is a test, using text.
@mkheck
mkheck / RequestHeaderFilterExample
Created June 8, 2017 15:51
Example of request header filtering by content type in a Spring RestController
@RestController
class MapFilterController {
@GetMapping(value = "/test", headers = "content-type=text/*")
public String getTestText() {
return "This is a test, using text.";
}
@GetMapping(value = "/test", headers = "content-type=application/json")
public Map<String, String> getTestJson() {
@RepositoryRestResource
interface QuoteRepository extends CrudRepository<Quote, Long> {
@Query("select q from Quote q order by RAND()")
public List<Quote> getQuotesRandomOrder();
}
---
applications:
- name: example-app
path: target/example-app-0.0.1-SNAPSHOT.jar
memory: 512M
random-route: true
{
"_embedded" : {
"readings" : [ {
"temperature" : 25.0,
"humidity" : 34.0,
"_links" : {
"self" : {
"href" : "http://localhost:8080/readings/1"
},
"reading" : {
curl localhost:8080/readings
curl -X POST -H "Content-Type: application/json" -d "{\"temperature\": 26.0, \"humidity\": 35.0}" localhost:8080/readings
package org.thehecklers;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource
public interface ReadingRepository extends CrudRepository<Reading, Long> {
}
package org.thehecklers;
import org.springframework.stereotype.Component;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
@mkheck
mkheck / wpa_supplicant.conf-UNHIDDEN
Last active August 29, 2015 14:16
Entry in Raspberry Pi (Raspbian) /etc/wpa_supplicant/wpa_supplicant.conf file network section for UNhidden SSID
disabled=1