You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: practices/development/examples/go-microservice-monorepo/doc/Authentication.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ request, but doesn't otherwise enforce use of credentials when hitting the API.
10
10
The `auth` package provides a JWT extractor function to retrieve the claims parsed by the authentication middleware.
11
11
This function is called `auth.RetrieveKeycloakClaims()`, and because the authentication token may not always be present,
12
12
it returns a boolean in addition to the returned data structure stating whether the token is present or not. It is recommended
13
-
that you respond with a 401 Unauthorized if you expect the token to be present. See the [microservice architecture docs](Microservice Architecture.md#writing-rest-controllers-driving-adapters)
13
+
that you respond with a 401 Unauthorized if you expect the token to be present. See the [microservice architecture docs](Microservice%20Architecture.md#writing-rest-controllers-driving-adapters)
14
14
for information on writing REST controllers.
15
15
16
16
Here's an example of using `auth.RetrieveKeycloakClaims()`:
Copy file name to clipboardExpand all lines: practices/development/examples/go-microservice-monorepo/doc/Configuration.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ If those checks do not pass, construction of the registry fails with an error de
55
55
56
56
Configuration options are created with the `config.NewOption()` function. It takes two parameters - the name of the configuration option
57
57
in the environment and whether the option should be required or not. These options are defined in the **options** package if
58
-
they're specific to a certain microservice or **sharedoptions** if the option is shared across multiple microservices. See [the repository layout docs](Navigation and Repository Layout.md)
58
+
they're specific to a certain microservice or **sharedoptions** if the option is shared across multiple microservices. See [the repository layout docs](Navigation%20and%20Repository%20Layout.md)
59
59
for information on where those are. These options can also be documented, so one can see what a configuration option is for when
60
60
retrieved from a registry.
61
61
@@ -72,7 +72,7 @@ var TheAdditionalTopping = config.NewOption("ADDITIONAL_TOPPING", false)
72
72
### Creating a validated configuration option
73
73
74
74
Configuration options can also use `jellydator/validation` validators to validate the content of configuration options. See
75
-
the [validation documentation](Microservice Architecture.md#dtos-validation-and-responding) for more information on validation.
75
+
the [validation documentation](Microservice%20Architecture.md#dtos-validation-and-responding) for more information on validation.
76
76
These validations are run during the construction of the configuration registry to verify everything is in the correct format.
77
77
Validations only run if the option is present, in the case of optional validation options.
78
78
To create a validated configuration option, you can either construct it via the alternate constructor `config.NewValidatedOption()`
@@ -91,7 +91,7 @@ var ShortConfigOption = config.NewValidatedOption("SHORT_CONFIG_OPTION", false,
91
91
### Creating a configuration registry and registering options
92
92
93
93
Configuration options are registered with a configuration registry via a `config.RegistryBuilder` which should be defined in
94
-
a microservice's **options** package. See the [repository layout docs](Navigation and Repository Layout.md) for where that is.
94
+
a microservice's **options** package. See the [repository layout docs](Navigation%20and%20Repository%20Layout.md) for where that is.
95
95
Once all the options are added, the `RegistryBuilder.VerifyAndBuild()` function is invoked which verifies the configuration in the
Copy file name to clipboardExpand all lines: practices/development/examples/go-microservice-monorepo/doc/Logging.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -45,13 +45,13 @@ configuration, the "production" state is determined by the `sharedoptions.IsInPr
45
45
simple constructor parameter.
46
46
47
47
See ["Instantiating the logger"](#instantiating-the-logger) for more information on constructing the
48
-
logger, and [the repository layout docs](Navigation and Repository Layout.md#layout-of-the-common-library)
48
+
logger, and [the repository layout docs](Navigation%20and%20Repository Layout.md#layout-of-the-common-library)
49
49
for more information on shared configuration options.
50
50
51
51
## Adjusting the log level
52
52
53
53
Log level filters are controlled by both the shared option `sharedoptions.LogLevel` and the shared log level controller defined in the `loglevel` shared feature.
54
-
See [the repository layout docs](Navigation and Repository Layout.md) for where to find those packages in the repo.
54
+
See [the repository layout docs](Navigation%20and%20Repository Layout.md) for where to find those packages in the repo.
55
55
56
56
The `loglevel` shared feature exposes HTTP endpoints for live-updating the application log level in production without an application restart.
In order to make error responses consistent across the application and reduce the amount of boilerplate necessary, several
401
401
error response functions are available to quickly respond with different HTTP status codes and report an error. These
402
-
error response functions are available in the `response` package (see [repository layout](Navigation and Repository Layout.md)
402
+
error response functions are available in the `response` package (see [repository layout](Navigation%20and%20Repository%20Layout.md)
403
403
for where that is).
404
404
405
405
The `response.APIErrorHelper` type returned from the canned response functions can be customized after its construction
@@ -485,7 +485,7 @@ wrapping any inserts triggered by driven ports will be automatically rolled back
485
485
### Attaching controllers to the router
486
486
487
487
REST controllers implementing the `router.Controller` interface can be attached to the `router.Router` instance via the
488
-
`router.Router.AttachControllers()` function. Each controller is instantiated in its own function in `bootstrap.go` (see [repo layout docs](Navigation and Repository Layout.md))
488
+
`router.Router.AttachControllers()` function. Each controller is instantiated in its own function in `bootstrap.go` (see [repo layout docs](Navigation%20and%20Repository%20Layout.md))
489
489
and added to the slice of controllers, which is passed along to the `AttachControllers()` function. Here's a small example,
490
490
using the sample controller as seen in the previous examples:
The database connection is attached to the context via the database context middleware, as described in [the middleware docs](Middleware.md#database-connection-middleware).
548
-
You can see all the querying options available on the `database.Connection` type (see the [repo layout](Navigation and Repository Layout.md)
548
+
You can see all the querying options available on the `database.Connection` type (see the [repo layout](Navigation%20and%20Repository%20Layout.md)
Copy file name to clipboardExpand all lines: practices/development/examples/go-microservice-monorepo/doc/Navigation and Repository Layout.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -11,16 +11,16 @@ layout, making it easy to find different parts of the API/business logic/etc.
11
11
***auth** - Contains code for extracting authentication information from incoming requests, as well as data structures representing the contents of authentication information. For more info, see [Authentication.md](./Authentication.md).
12
12
***config** - Contains code for defining configuration options and retrieving them from a configuration registry. For more information see [Configuration.md](./Configuration.md)
13
13
***sharedoptions** - Contains common configuration options that may be used by all microservices
14
-
***database** - Contains database-related code, including functions for managing transactions and extracting the database connection from the current request context. Relevant information can be found in [Middleware.md](./Middleware.md), [Microservice Architecture.md](./Microservice Architecture.md), and [Testing.md](./Testing.md).
14
+
***database** - Contains database-related code, including functions for managing transactions and extracting the database connection from the current request context. Relevant information can be found in [Middleware.md](./Middleware.md), [Microservice Architecture.md](./Microservice%20Architecture.md), and [Testing.md](./Testing.md).
15
15
***logger** - Contains the global logger instance and functions for initializing it. For more information, see [Logging.md](./Logging.md).
16
-
***request** - Contains utilities for extracting information from requests, such as deserializing the request body or pulling out the request context. For more information, see [Microservice Architecture.md](./Microservice Architecture.md).
16
+
***request** - Contains utilities for extracting information from requests, such as deserializing the request body or pulling out the request context. For more information, see [Microservice Architecture.md](./Microservice%20Architecture.md).
17
17
***testhelper** - Contains utilities for building HTTP requests in test code. See [Testing.md](./Testing.md) for more information.
18
-
***response** - Contains utilities for generating a standard error structure on HTTP responses. For more information, see [Microservice Architecture.md](./Microservice Architecture.md).
18
+
***response** - Contains utilities for generating a standard error structure on HTTP responses. For more information, see [Microservice Architecture.md](./Microservice%20Architecture.md).
19
19
***dtos** - Contains code for common DTO types used in HTTP responses
20
20
***testhelper** - Contains utilities for deserializing HTTP response bodies into data structures in tests. See [Testing.md](./Testing.md) for more information.
21
21
***types** - Contains useful types for representing things in your code such as nullable values.
22
22
***sharedfeatures** - Contains common software features and controllers that can be used across microservices
23
-
***FEATURE NAME** - The name of the folder describes the microservice feature implemented by the business logic in this directory. See [Microservice Architecture.md](./Microservice Architecture.md) for more information.
23
+
***FEATURE NAME** - The name of the folder describes the microservice feature implemented by the business logic in this directory. See [Microservice Architecture.md](./Microservice%20Architecture.md) for more information.
24
24
***controller** - Contains REST controller definitions and DTOs which use and drive the business logic
25
25
***adapter** - Contains external access adapters used by the business logic to access or send data in external systems, such as message queues or databases.
26
26
@@ -35,6 +35,6 @@ to package-level stuff.
35
35
***bootstrap.go** - Functions invoked by main.go to stand up the subsystems of the application, such as initializing the logger and connecting to the database. It also has functions for creating the HTTP router and attaching routes from all REST controllers in the app.
36
36
***options** - Contains the global configuration registry and initialization functions for it. See [Configuration.md](./Configuration.md) for more information.
37
37
***features** - Contains implementations for features that the microservice exposes
38
-
***FEATURE NAME** - The name of the folder describes the microservice feature implemented by the business logic in this directory. See [Microservice Architecture.md](./Microservice Architecture.md) for more information.
38
+
***FEATURE NAME** - The name of the folder describes the microservice feature implemented by the business logic in this directory. See [Microservice Architecture.md](./Microservice%20Architecture.md) for more information.
39
39
***controller** - Contains REST controller definitions which use and drive the business logic
40
40
***adapter** - Contains external access adapters used by the business logic to access or send data in external systems, such as message queues or databases
Copy file name to clipboardExpand all lines: practices/development/examples/go-microservice-monorepo/doc/Rest API Conventions.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -70,7 +70,7 @@ Entries can be added to the collection by using the HTTP verb `POST`. `PUT` may
70
70
(update if exists, otherwise insert) rather than an insertion into the collection. Requests made with these verbs
71
71
contain the contents of the new entry in the request body.
72
72
73
-
Fields in request bodies should be camel cased (via the go "json" struct tag, see [the microservice architecture docs](Microservice Architecture.md#dtos-validation-and-responding)
73
+
Fields in request bodies should be camel cased (via the go "json" struct tag, see [the microservice architecture docs](Microservice%20Architecture.md#dtos-validation-and-responding)
74
74
for more info) and acronyms should only capitalize the first letter.
0 commit comments