// Path: halfpipe-consul/src/main/java/halfpipe/consul/ConsulConfigurer.java
// public class ConsulConfigurer extends ClientConfigurer {
// 
//     protected <T> LoadBalancingTarget<T> loadBalance(Class<T> type, String schemeName) {
// //        Target.HardCodedTarget<PostClient> target = new Target.HardCodedTarget<>(PostClient.class, "http://postServer");
// //        PostClient postClient = ObjectGraph.create(/*new Feign.Defaults(), */client, new RibbonModule()).get(Feign.class).newInstance(target);
//         //return client.target(PostClient.class, "http://localhost:8080");
//         String name = URI.create(schemeName).getHost();
//         //TODO: figure out how to set this property dynamically
//         setServiceListClass(name);
//         //System.setProperty(name + ".ribbon.NIWSServerListClassName", ConsulServerList.class.getName());
//         LoadBalancingTarget<T> target = LoadBalancingTarget.create(type, schemeName);
//         return target;
//     }
// }
// 
// Path: halfpipe-example-service/src/main/java/halfpipe/example/client/PostClient.java
// public interface PostClient {
//     @RequestLine("POST /v1/posts")
//     Post create(Post post);
// 
//     @RequestLine("GET /v1/posts")
//     List<Post> posts();
// 
//     @RequestLine("GET /v1/posts")
//     Future<List<Post>> postsAsync();
// 
//     @RequestLine("GET /v1/posts")
//     HystrixExecutable<List<Post>> postsExecutable();
// 
//     //TODO: this is odd, should be Observable<Post>, need hint
//     @RequestLine("GET /v1/posts")
//     Observable<List<Post>> postsObserve();
// }
// 
// Path: halfpipe-example-service/src/main/java/halfpipe/example/model/Post.java
// @Entity
// @Data
// @ApiModel("A blog post")
// public class Post implements Serializable {
//     @Id
//     @GeneratedValue
//     @ApiModelProperty(value = "The post id")
//     private Long id;
// 
//     @Column(nullable = false)
//     @ApiModelProperty(value = "The post title", required = true)
//     private String title;
// 
//     @Column(nullable = false)
//     @ApiModelProperty(value = "The post body", required = true)
//     private String body;
// 
//     @Column(nullable = false)
//     @ApiModelProperty(value = "The post author", required = true)
//     private String author;
// 
// }


import com.google.common.base.Supplier;
import com.google.common.collect.Lists;
import feign.Logger;
import feign.auth.BasicAuthRequestInterceptor;
import halfpipe.consul.ConsulConfigurer;
import halfpipe.example.client.PostClient;
import halfpipe.example.model.Post;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import java.util.List;
package halfpipe.example.frontend;



@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackageClasses = ExampleFrontendApp.class)
public class ExampleFrontendApp extends ConsulConfigurer {

    @Bean
    public PostClient postClient() {
        return client()
                .requestInterceptor(new BasicAuthRequestInterceptor("test", "test123"))
                .logLevel(Logger.Level.FULL)
// Path: halfpipe-consul/src/main/java/halfpipe/consul/ConsulConfigurer.java
// public class ConsulConfigurer extends ClientConfigurer {
// 
//     protected <T> LoadBalancingTarget<T> loadBalance(Class<T> type, String schemeName) {
// //        Target.HardCodedTarget<PostClient> target = new Target.HardCodedTarget<>(PostClient.class, "http://postServer");
// //        PostClient postClient = ObjectGraph.create(/*new Feign.Defaults(), */client, new RibbonModule()).get(Feign.class).newInstance(target);
//         //return client.target(PostClient.class, "http://localhost:8080");
//         String name = URI.create(schemeName).getHost();
//         //TODO: figure out how to set this property dynamically
//         setServiceListClass(name);
//         //System.setProperty(name + ".ribbon.NIWSServerListClassName", ConsulServerList.class.getName());
//         LoadBalancingTarget<T> target = LoadBalancingTarget.create(type, schemeName);
//         return target;
//     }
// }
// 
// Path: halfpipe-example-service/src/main/java/halfpipe/example/client/PostClient.java
// public interface PostClient {
//     @RequestLine("POST /v1/posts")
//     Post create(Post post);
// 
//     @RequestLine("GET /v1/posts")
//     List<Post> posts();
// 
//     @RequestLine("GET /v1/posts")
//     Future<List<Post>> postsAsync();
// 
//     @RequestLine("GET /v1/posts")
//     HystrixExecutable<List<Post>> postsExecutable();
// 
//     //TODO: this is odd, should be Observable<Post>, need hint
//     @RequestLine("GET /v1/posts")
//     Observable<List<Post>> postsObserve();
// }
// 
// Path: halfpipe-example-service/src/main/java/halfpipe/example/model/Post.java
// @Entity
// @Data
// @ApiModel("A blog post")
// public class Post implements Serializable {
//     @Id
//     @GeneratedValue
//     @ApiModelProperty(value = "The post id")
//     private Long id;
// 
//     @Column(nullable = false)
//     @ApiModelProperty(value = "The post title", required = true)
//     private String title;
// 
//     @Column(nullable = false)
//     @ApiModelProperty(value = "The post body", required = true)
//     private String body;
// 
//     @Column(nullable = false)
//     @ApiModelProperty(value = "The post author", required = true)
//     private String author;
// 
// }


// Path: halfpipe-example-frontend/src/main/java/halfpipe/example/frontend/ExampleFrontendApp.java
import com.google.common.base.Supplier;
import com.google.common.collect.Lists;
import feign.Logger;
import feign.auth.BasicAuthRequestInterceptor;
import halfpipe.consul.ConsulConfigurer;
import halfpipe.example.client.PostClient;
import halfpipe.example.model.Post;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import java.util.List;

package halfpipe.example.frontend;



@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackageClasses = ExampleFrontendApp.class)
public class ExampleFrontendApp extends ConsulConfigurer {

    @Bean
    public PostClient postClient() {
        return client()
                .requestInterceptor(new BasicAuthRequestInterceptor("test", "test123"))
                .logLevel(Logger.Level.FULL)
                .target(loadBalance(PostClient.class, "http://exampleService"));