Spring-Cloud-Gateway Custom Gateway Filter

The scope of GatewayFilter is the specified routing configuration, and the routing configuration options require filters to specify the list of GatewayFilters that you want to use. We can customize the GatewayFilter to do additional extensions to achieve some functionality that does not exist in the built-in GatewayFilter and apply it to our routing configuration. How to customize GatewayFilter To customize GatewayFilter, you need to implement the org.springframework.cloud.gateway.filter.factory.GatewayFilterFactory interface, and the definition of GatewayFilterFactory is as follows.

Fetch Api Tutorials

fetch() is an upgraded version of XMLHttpRequest used to make HTTP requests inside JavaScript scripts. The browser provides this object natively. This article describes its usage in detail. 1. Basic usage The function of fetch() is basically the same as XMLHttpRequest, but with three main differences. fetch() uses Promise and does not use a callback function, so it is much simpler to write and more concise. The modular design of fetch(), with API spread over multiple objects (Response object, Request object, Headers object), is more reasonable; in contrast, the API design of XMLHttpRequest is not very good, with input, output and state all managed in the same interface, making it easy to write very confusing code.

Be Aware of Security Vulnerability Caused by Spring Boot Actuator

Recently, we have been particularly disturbed by various security vulnerabilities, and we have received dozens of vulnerability emails scanned by the security team in a week, which have a class of vulnerabilities that are easy to ignore, but have an extremely wide impact and are extremely harmful, and you should not be unfamiliar with my name, which is Spring Boot Actuator. Before writing this article, I did a little survey with my friends asking them about their knowledge of the Spring Boot Actuator and the results were surprisingly consistent, everyone knows that Spring Boot provides automatic configuration of the spring-boot-starter-actuator, but very few people but few people actually use its related features.

Sqlx Library Usage Guide

In projects we may usually use database/sql to connect to MySQL databases. This article introduces the sqlx.In and DB.NamedExec methods in sqlx that you may have overlooked, with the help of an example of using sqlx to achieve bulk insert data. Introduction to sqlx In a project we may usually use database/sql to connect to a MySQL database. sqlx can be thought of as a superset of the Go language’s

Several Ways to Convert Struct to map[string]interface{}

This article describes the “pitfalls” you need to know when converting struct to map[string]interface{} in Go, and also some of the methods you need to know. We usually use struct in Go to store our data, for example, to store user information, we might define the following struct. 1 2 3 4 5 6 7 // UserInfo type UserInfo struct { Name string `json:"name"` Age int `json:"age"` } u1 := UserInfo{Name: "q1mi", Age: 18} struct to map[string]interface JSON serialization method Serialize u1 with JSON, then deserialize to map

Why Will Spring Remain One of the Best Platforms in the Cloud Native Era

Back in 2015, the keynote at the SpringOne 2015 conference in Washington was Cloud Native Enterprise. The slogan of that conference was also Cloud Native and the posters were all over the place with Cloud Native. You may wonder how you could call it Cloud Native when containers weren’t popular at that time. Although many people may not have the same understanding of Cloud Native, more and more people believe that “Cloud native is about culture, not containers”.

Certify Your Git Commits on Github With GPG

Because of the email-based identity verification feature of Git, you can easily fake being someone else to make a Commit. How do you ensure that the Commit is really a developer commit? This is where a special key, the GPG key, is needed for authentication. About GPG GNU Privacy Guard (GnuPG or GPG) is a cryptographic software for encrypting and signing communication content and managing keys for asymmetric cryptography. Asymmetric cryptography is a technique that you should have come across, and it is used in many fields.

Vite + React Component Development Practice

1. Vite brings the light It’s no exaggeration to say that Vite has brought an absolute revolution to the front-end. Or we can say that the integration of esbuild, Browser es modules, HMR, Pre-Bundling, and other advanced tools and ideas about JS compilation development in the community behind Vite has brought about a revolutionary changes. The main reason why Vite is faster is that esbuild does pre-bundles dependencies + browser native ESM dynamic compilation, which I won’t go into too much detail here

Introduction to Introspector for Java

This article mainly analyzes the usage of Introspector. Introspector is a tool class that deals specifically with JavaBean and is used to get the descriptors in JavaBean. The commonly used descriptor-related classes of JavaBean are BeanInfo, PropertyDescriptor, MethodDescriptor, BeanDescriptor, EventSetDescriptor and ParameterDescriptor. The following will slowly analyze how these classes are used, as well as some of the features of Introspector. What is JavaBean JavaBean is a special (actually, it’s okay to say ordinary, it’s not very special) class, mainly used to pass data information, the methods in this class are mainly used to access private fields, and the method names conform to some naming rules (fields are private, each field has Setter and Getter methods, methods and fields named to meet the first letter lower case hump naming ).

Spring Master Slave Databas Configuration and Dynamic Datasource Switching Principles

In large applications, it is a common design pattern to configure master-slave databases and use read-write separation. In Spring applications, to implement read-write separation, it is best to not make changes to existing code, but to support it transparently at the bottom. Spring has a built-in AbstractRoutingDataSource that can configure multiple data sources into a Map and then, depending on the key, return different data sources. Because AbstractRoutingDataSource is also a DataSource interface, the application can set the key first, and the code that accesses the database can get the corresponding real data source from AbstractRoutingDataSource to access the specified database.

Real Time Hot Reloading of Go Programs Using Air

Today we want to introduce a magic tool - Air can listen to the project’s code files in real time, and automatically recompile and execute the code after changes, greatly improving the development efficiency of gin framework projects. Why do I need real-time loading When using Python to write Web projects, the common Flask or Django frameworks support live-loading, and after you modify the project code, the program can automatically reload and execute (live-reload), which is very convenient in the daily development phase.

React Code Sharing Best Practices Approach

When any project grows to a certain complexity, it is bound to face the problem of logic reuse. In React, there are several ways to implement logic reuse: Mixin, HOC, Decorator, Render Props, Hook, etc. This article mainly analyzes the advantages and disadvantages of these ways to help developers make a more suitable way for business scenarios. Mixin Mixin has been widely used in various object-oriented languages to create a

Fasttemplate Simple Tutorial

fasttemplate is a relatively simple and easy to use small template library . The author of fasttemplate, valyala, has additionally open sourced a number of excellent libraries, such as the famous fasthttp. fasttemlate only focuses on a very small area - string replacement. Its goal is to replace strings.Replace, fmt.Sprintf and other methods to provide a simple, easy-to-use, high-performance string replacement method. Quick Use Create the directory and initialize. 1 2 $ mkdir fasttemplate && cd fasttemplate $ go mod init github.

Analysis of the Problems Caused by Replacing Fastjson With Gson

The security vulnerability of Json serialization framework has always been a topic of conversation among programmers, especially in the past two years, fastjson has been targeted research, and more frequently reported vulnerabilities, a vulnerability does not matter, but the security team is always using email to urge the online application to upgrade the dependency, which can be fatal, I believe that many people are also unbearable, consider using other serialization framework to replace fastjson.

Go os/exec Short Tutorial

The Go standard library provides convenient methods to run external commands easily. Generally we use the methods under the os/exec package to execute external commands and interact with external commands. os/exec wraps the os.StartProcess method for easier access to input and output, providing I/O pipe and other features. I will dedicate two articles to Go’s methods for starting new processes and executing external commands, this is the first one, dedicated to the os/exec library.

PostgreSQL Jsonpath Usage in Practice

jsonpath is a tool used to parse json data, similar to xpath, jsonpath can parse very complex json data. PostgreSQL json development history. postgreSQL has supported json data type since 9.2, but due to the poor performance of parsing json data, it is not favored by everyone, but choose to use nosql database instead. So from pg9.4 onwards, the jsonb data type was supported. Compared to the json type, jsonb does not need to be parsed every time it is used, so the performance is much improved, and it also supports index queries and so on.

Using Gomock for Unit Testing in Go

In real projects, when you need to do unit testing. But often you find that there are a lot of dependencies. That’s where Gomock comes in handy! Gomock is an official mock framework for the Go language Installation 1 2 $ go get -u github.com/golang/mock/gomock $ go install github.com/golang/mock/mockgen Step 1: We will install the gomock third-party library and the mock code generation tool, mockgen, which will save us a lot of work.

Rsync Usage Tutorial

1. Introduction rsync is a commonly used Linux application for file synchronization. It can synchronize files between the local computer and a remote computer, or between two local directories (but does not support synchronization between two remote computers). It can also be used as a file copying tool, replacing the cp and mv commands. The r in its name refers to remote, rsync actually means “remote synchronization”. Unlike other file transfer tools (such as FTP or scp), rsync’s main feature is that it checks the existing files of both the sender and the receiver and only transfers the parts that have changed (the default rule is that the file size or modification time has changed).

Hadoop and Hive Development Environment Build on Windows10

There are numerous problems with the installation and operation of components such as Hadoop and Hive on Windows systems With the help of several Internet references, I completed the construction of Hadoop and Hive development environment on Windows 10. This article documents the specific steps, problems encountered, and corresponding solutions for the entire build process. Environmental Preparation Software Version Description Windows 10 Operating System JDK 8 Do not use a version greater than or equal to JDK9 for the time being, because unknown exceptions will occur when starting the virtual machine MySQL 8.

Several Ways to Stop Goroutine in Golang

goroutine case In our daily work, we often have code that starts a goroutine using the go keyword. 1 2 3 4 5 6 7 8 func main() { ch := make(chan string, 6) go func() { for { ch <- "Hello" } }() } A first-time goroutine developer may think it’s over, but after running for a while, he may run into some problems and struggle to figure out…