Skip to content

Commit

Permalink
Revert "docs: tiny adjustment on server configuration" (#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
yohamta authored Nov 19, 2024
1 parent e86d69e commit 678dd21
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/source/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Server Configuration
~~~~~~~~~~~~~~~~~~
- ``DAGU_HOST`` (``127.0.0.1``): Server binding host
- ``DAGU_PORT`` (``8080``): Server binding port
- ``DAGU_BASE_PATH`` (``""``): Base path to serve the application. E.g., ``/dagu``
- ``DAGU_BASE_PATH`` (``""``): Base path to serve the application
- ``DAGU_TZ`` (``""``): Server timezone (default: system timezone)
- ``DAGU_CERT_FILE``: SSL certificate file path
- ``DAGU_KEY_FILE``: SSL key file path
Expand Down
2 changes: 1 addition & 1 deletion docs/source/scheduler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Or you can set multiple schedules.
- name: scheduled job
command: job.sh
You can also specify a cron expression to run within a specific timezone. See `list of tz database timezones <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>`_.
You can also specify a cron expression to run within a specific timezone. See `list of tz database timezones <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>`

.. code-block:: yaml
Expand Down
17 changes: 13 additions & 4 deletions internal/frontend/middleware/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var (
authBasic *AuthBasic
authToken *AuthToken
appLogger logger.Logger
basePath string
)

type Options struct {
Expand All @@ -96,16 +97,24 @@ func Setup(opts *Options) {
authBasic = opts.AuthBasic
authToken = opts.AuthToken
appLogger = opts.Logger
basePath = opts.BasePath
}

func prefixChecker(next http.Handler) http.Handler {
return http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(r.URL.Path, "/api") {
next.ServeHTTP(w, r)
} else {
defaultHandler.ServeHTTP(w, r)
if basePath != "" && r.URL.Path == "/" {
http.Redirect(w, r, basePath, http.StatusSeeOther)
return
}

http.StripPrefix(basePath, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(r.URL.Path, "/api") {
next.ServeHTTP(w, r)
} else {
defaultHandler.ServeHTTP(w, r)
}
})).ServeHTTP(w, r)
})
}

Expand Down

0 comments on commit 678dd21

Please sign in to comment.