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
@Endpoint | |
public class CountryEndpoint { | |
private static final String NAMESPACE_URI = "http://spring.io/guides/gs-producing-web-service"; | |
private CountryRepository countryRepository; | |
@Autowired | |
public CountryEndpoint(CountryRepository countryRepository) { | |
this.countryRepository = countryRepository; | |
} |
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 hello; | |
import java.util.concurrent.atomic.AtomicLong; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RequestParam; | |
import org.springframework.web.bind.annotation.RestController; | |
@RestController | |
public class GreetingController { |
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
router.get('/', async (req, res) => { | |
const users = await User.find(); | |
return res.send({ users }); | |
}); | |
router.post('/login', async (req, res, next) => { | |
const { name, password } = req.body; | |
try { |
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
public static void main(String[] args) throws UnknownHostException { | |
SpringApplication app = new SpringApplication(AngularspringbootmicrosservicoApp.class); | |
DefaultProfileUtil.addDefaultProfile(app); | |
Environment env = app.run(args).getEnvironment(); | |
String protocol = "http"; | |
if (env.getProperty("server.ssl.key-store") != null) { | |
protocol = "https"; | |
} | |
log.info("\n----------------------------------------------------------\n\t" + | |
"Application '{}' is running! Access URLs:\n\t" + |
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
[Route("api/[controller]")] | |
public class ValuesController : Controller | |
{ | |
// GET api/values | |
[HttpGet] | |
public IEnumerable<string> Get() | |
{ | |
return new string[] { "value1", "value2" }; | |
} |
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
[RoutePrefix("api/books")] | |
public class ControladorLivros : ApiController | |
{ | |
[Route("api/livros")] | |
public IEnumerable<Livro> ObterLivros() { ... } | |
[Route("api/livros/{id:int}")] | |
public Livro ObterLivro(int id) { ... } | |
[Route("api/livros")] |
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
<!doctype html> | |
<html> | |
<head> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function () { | |
$('#user-submit').click(function () { | |
var payload = { | |
name: $('#user-name').val() | |
}; |
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
{ | |
"name": "AloMundoNodeMysql" | |
, "description": "Demonstração de como usar o Express e MySQL juntos" | |
, "author": "Modificado por *Seu nome*" | |
, "version": "0.0.1" | |
, "private": true | |
, "dependencies": { | |
"express": "~2.5", | |
"mysql": "~2.0" | |
} |
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
// Aplicacao minima Node.JS com MySQL | |
// Carrega modulos express em mysql | |
var express = require('express'), | |
mysql = require('mysql'); | |
// Inicializa conexao com o banco de dados e servidor Web express | |
var connection = mysql.createConnection({ | |
host : 'localhost', |
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
// Carga de modulos em Javascript. Aqui estou carregando o modulo HTTP, que dar | |
//suporte a requisicoes em protocolo HTTP | |
var http = require('http'); | |
// Nesta linha eu crio um servidor Web, que irá ouvir requisições no porto 8080. | |
// Toda conexao a esse servidor será tratado por uma função criada pelo desenvolvedor. | |
// Esta funcao gera um cabeçalho HTTP 200 (OK) e então ecoa uma mensagem para | |
//o navegador que originou a requisição. | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); |
NewerOlder