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
@RestController() | |
public class FileController implements FileApi { | |
public FileMetadata getFile(String id) { | |
return new FileMetadata(id, "test-file", 100, "contents".getBytes()); | |
} | |
public List<FileMetadata> searchFiles(String name) { | |
List<FileMetadata> list = new ArrayList<>(); | |
list.add(new FileMetadata("id-1", name + "-random1", 100, "contents 1".getBytes())); |
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
@RequestMapping("file") | |
public interface FileApi { | |
@GetMapping("/{id}") | |
FileMetadata getFile(@PathVariable String id); | |
@GetMapping("/search") | |
List<FileMetadata> searchFiles(@RequestParam(name = "name") String name); | |
@PostMapping("/save") |
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
<dependency> | |
<groupId>org.springframework.cloud</groupId> | |
<artifactId>spring-cloud-starter-openfeign</artifactId> | |
<version>3.0.1</version> | |
</dependency> | |
<dependencyManagement> | |
<dependencies> | |
<dependency> | |
<groupId>org.springframework.cloud</groupId> |
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
@Component | |
public class LogRequestFilter implements Filter { | |
@Override | |
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, | |
FilterChain filterChain) throws IOException, ServletException { | |
HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; | |
if(Arrays.asList("POST", "PUT").contains(httpRequest.getMethod())) { | |
CustomHttpRequestWrapper requestWrapper = new CustomHttpRequestWrapper(httpRequest); |
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.filters; | |
import java.io.BufferedInputStream; | |
import java.io.BufferedReader; | |
import java.io.ByteArrayInputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.io.StringReader; | |
import java.nio.charset.Charset; |
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
@Component | |
public class LogRequestFilter implements Filter { | |
private final Logger logger = LoggerFactory.getLogger(LogRequestFilter.class); | |
@Override | |
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, | |
FilterChain filterChain) throws IOException, ServletException { | |
logPostOrPutRequestBody((HttpServletRequest) servletRequest); | |
filterChain.doFilter(servletRequest, servletResponse); |
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
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
} | |
} | |
} | |
provider "aws" { |
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
exports.handler = async (event, context, callback) => { | |
const request = event.Records[0].cf.request; | |
const headers = request.headers; | |
const user = 'YOUR_USERNAME_HERE'; | |
const pass = 'YOUR_PASSWORD_HERE'; | |
const basicAuthentication = 'Basic ' + new Buffer(user + ':' + pass).toString('base64'); |
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 Producer extends Thread{ | |
public String producerName; | |
Buffer<String> buffer; | |
public Producer(String name, Buffer<String> buffer) { | |
this.producerName = name; | |
this.buffer = buffer; | |
} |
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 Buffer<T> { | |
List<T> items; | |
private int capacity; | |
private Semaphore consumeSemaphore = new Semaphore(0); | |
private Semaphore produceSemaphore = new Semaphore(1); | |
private Semaphore pcCoordinatorSemaphore = new Semaphore(1); |