rest

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright © 2024-2025 Thomas von Dein

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This logging middleware is based on

https://github.com/elithrar/admission-control/blob/v0.6.3/request_logger.go

	by Matt Silverlock licensed under the Apache-2.0 license.

   I am using slog and added a couple of small modifications.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Home

func Home(resp http.ResponseWriter)

func JsonStatus

func JsonStatus(resp http.ResponseWriter, code int, msg string)

Wrapper to respond with proper json status, message and code, shall be prepared and called by the handlers directly.

func LogHandler

func LogHandler() func(http.Handler) http.Handler

LoggingMiddleware logs the incoming HTTP request & its duration.

func RestDelete

func RestDelete(resp http.ResponseWriter, req *http.Request, key string, conf *cfg.Config)

func RestGet

func RestGet(resp http.ResponseWriter, req *http.Request, key string, conf *cfg.Config)

func RestList

func RestList(resp http.ResponseWriter, req *http.Request, conf *cfg.Config)

func RestSet

func RestSet(resp http.ResponseWriter, req *http.Request, conf *cfg.Config)

func Runserver

func Runserver(conf *cfg.Config, args []string) error

Types

type ListResponse

type ListResponse struct {
	Success bool
	Code    int
	Entries app.DbEntries
}

type Result

type Result struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Code    int    `json:"code"`
}

used to return to the api client

type SetContext

type SetContext struct {
	Query string `json:"query" form:"query"`
}

type SingleResponse

type SingleResponse struct {
	Success bool
	Code    int
	Entry   *app.DbEntry
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL