8000 [pull] main from miniflux:main by pull[bot] · Pull Request #189 · suhaoGe/miniflux · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions internal/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ func NewConfigOptions() *configOptions {
ValueType: secretFileType,
TargetKey: "DATABASE_URL",
},
"DISABLE_API": {
ParsedBoolValue: false,
RawValue: "0",
ValueType: boolType,
},
"DISABLE_HSTS": {
ParsedBoolValue: false,
RawValue: "0",
Expand Down Expand Up @@ -711,6 +716,10 @@ func (c *configOptions) HasHTTPClientProxiesConfigured() bool {
return len(c.options["HTTP_CLIENT_PROXIES"].ParsedStringList) > 0
}

func (c *configOptions) HasAPI() bool {
return !c.options["DISABLE_API"].ParsedBoolValue
}

func (c *configOptions) HasHTTPService() bool {
return !c.options["DISABLE_HTTP_SERVICE"].ParsedBoolValue
}
Expand Down
4 changes: 3 additions & 1 deletion internal/http/server/httpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ func setupHandler(store *storage.Storage, pool *worker.Pool) *mux.Router {

fever.Serve(subrouter, store)
googlereader.Serve(subrouter, store)
api.Serve(subrouter, store, pool)
if config.Opts.HasAPI() {
api.Serve(subrouter, store, pool)
}
ui.Serve(subrouter, store, pool)

subrouter.HandleFunc("/healthcheck", readinessProbe).Name("healthcheck")
Expand Down
1 change: 1 addition & 0 deletions internal/template/functions.go
8000
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (f *funcMap) Map() template.FuncMap {
"truncate": truncate,
"isEmail": isEmail,
"baseURL": config.Opts.BaseURL,
"apiEnabled": config.Opts.HasAPI,
"rootURL": config.Opts.RootURL,
"disableLocalAuth": config.Opts.DisableLocalAuth,
"oidcProviderName": config.Opts.OAuth2OIDCProviderName,
Expand Down
2 changes: 2 additions & 0 deletions internal/template/templates/common/settings_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
<li>
<a href="{{ route "integrations" }}">{{ icon "third-party-services" }}{{ t "menu.integrations" }}</a>
</li>
{{ if apiEnabled }}
<li>
<a href="{{ route "apiKeys" }}">{{ icon "api" }}{{ t "menu.api_keys" }}</a>
</li>
{{ end }}
<li>
<a href="{{ route "sessions" }}">{{ icon "sessions" }}{{ t "menu.sessions" }}</a>
</li>
Expand Down
10 changes: 6 additions & 4 deletions internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ func Serve(router *mux.Router, store *storage.Storage, pool *worker.Pool) {
uiRouter.HandleFunc("/sessions/{sessionID}/remove", handler.removeSession).Name("removeSession").Methods(http.MethodPost)

// API Keys pages.
uiRouter.HandleFunc("/keys", handler.showAPIKeysPage).Name("apiKeys").Methods(http.MethodGet)
uiRouter.HandleFunc("/keys/{keyID}/delete", handler.deleteAPIKey).Name("deleteAPIKey").Methods(http.MethodPost)
uiRouter.HandleFunc("/keys/create", handler.showCreateAPIKeyPage).Name("createAPIKey").Methods(http.MethodGet)
uiRouter.HandleFunc("/keys/save", handler.saveAPIKey).Name("saveAPIKey").Methods(http.MethodPost)
if config.Opts.HasAPI() {
uiRouter.HandleFunc("/keys", handler.showAPIKeysPage).Name("apiKeys").Methods(http.MethodGet)
uiRouter.HandleFunc("/keys/{keyID}/delete", handler.deleteAPIKey).Name("deleteAPIKey").Methods(http.MethodPost)
uiRouter.HandleFunc("/keys/create", handler.showCreateAPIKeyPage).Name("createAPIKey").Methods(http.MethodGet)
uiRouter.HandleFunc("/keys/save", handler.saveAPIKey).Name("saveAPIKey").Methods(http.MethodPost)
}

// OPML pages.
uiRouter.HandleFunc("/export", handler.exportFeeds).Name("export").Methods(http.MethodGet)
Expand Down
5 changes: 5 additions & 0 deletions miniflux.1
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ Path to a secret key exposed as a file, it should contain $DATABASE_URL value\&.
.br
Default is empty\&.
.TP
.B DISABLE_API
Disable miniflux's API\&.
.br
Default is false (The API is enabled)\&.
.TP
.B DISABLE_HSTS
Disable HTTP Strict Transport Security header if \fBHTTPS\fR is set\&.
.br
Expand Down
0