This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ModelDummyUser(models.Model): | |
first_name = models.CharField(max_length=100) | |
last_name = models.CharField(max_length=100, null=False) | |
age = models.IntegerField(validators=[MinValueValidator(3), MaxValueValidator(100)]) | |
created_at = models.DateTimeField(auto_now_add=True, editable=False) | |
def get_absolute_url(self): | |
return reverse('demos-ui-createview') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: melardev.com | |
# Youtube video: https://youtu.be/PRw2Hw7yrS0 | |
from django.core.urlresolvers import reverse, reverse_lazy | |
from django.http import HttpResponseRedirect | |
from django.shortcuts import render | |
from django.views.generic.edit import CreateView | |
from demos.forms import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.melardev.cloud.ribbon; | |
import com.melardev.cloud.ribbon.config.RibbonConfiguration; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; | |
import org.springframework.cloud.netflix.ribbon.RibbonClient; | |
@SpringBootApplication(scanBasePackages = "com.melardev.cloud.ribbon.controllers") //important, otherwise crash | |
@EnableEurekaClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.melardev.cloud.ribbon.controllers; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.cloud.client.ServiceInstance; | |
import org.springframework.cloud.client.discovery.DiscoveryClient; | |
import org.springframework.cloud.client.loadbalancer.LoadBalanced; | |
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; | |
import org.springframework.stereotype.Controller; | |
import org.springframework.ui.Model; | |
import org.springframework.web.bind.annotation.RequestMapping; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.melardev.cloud.ribbon.config; | |
import com.netflix.client.config.IClientConfig; | |
import com.netflix.loadbalancer.*; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
@Configuration | |
public class RibbonConfiguration { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.melardev.cloud</groupId> | |
<artifactId>ribbon-rest</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<packaging>jar</packaging> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
application: | |
name: ribbon-service | |
server: | |
port: 8081 | |
rest-server: | |
ribbon: | |
eureka: true # By default Ribbon will get the actively running microservices from Eureka, let's disable that strategy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.melardev.cloud.eureka; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; | |
@SpringBootApplication | |
@EnableEurekaServer | |
public class EurekaApplication { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server: | |
port: 8761 | |
eureka: | |
client: | |
register-with-eureka: false | |
fetch-registry: false | |
instance: | |
lease-expiration-duration-in-seconds: 2 # wait up hearbeat for microservices up to 2 sec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.melardev.cloud.rest.controllers; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
@RestController | |
public class HomeController { | |
@Value("${app.id}") |
OlderNewer