horus

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2022 License: MIT Imports: 19 Imported by: 1

README

Horus 𓂀

horus-hero

Introduction

Horus is a request logger and viewer for Go. It allows developers log and view http requests made to their web application.

horus-big-brother

Installation

Run the following command to install Horus on your project:

go get github.com/ichtrojan/horus
Initiate horus
package main

import github.com/ichtrojan/horus

func main() {
    listener, err := horus.Init("mysql", horus.Config{
		DbName:    "{preferred_database_name}",
		DbHost:    "{preferred_database_host}",
		DbPssword: "{preferred_database_password}",
		DbPort:    "{preferred_database_port}",
		DbUser:    "{preferred_database_user}",
	})
}

NOTE
Supported database adapters include mysql and postgres

Serve dashboard (optional)
horus-message-received
...
if err := listener.Serve(":8081", "{preferred_password}")); err != nil {
	log.Fatal(err)
}
...

NOTE
Visit /horus on the port configured to view the dashboard

Usage

To enable horus to listen for requests, use the Watch middleware provided by horus on the endpoints you will like monitor.

...
http.HandleFunc("/", listener.Watch(func(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Content-Type", "application/json")

    response := map[string]string{"message": "Horus is live 👁"}

    _ = json.NewEncoder(w).Encode(response)
}))
...

You can explore the implementation in the example folder.

Built by

Documentation

Index

Constants

This section is empty.

Variables

View Source
var METHODS = map[string]string{
	"get":    "GET",
	"post":   "POST",
	"delete": "DELETE",
	"option": "OPTION",
	"put":    "PUT",
}

Functions

This section is empty.

Types

type Config

type Config struct {
	DbUser    string
	DbPssword string
	DbHost    string
	DbName    string
	DbPort    string
}

type Credentials

type Credentials struct {
	Key string
}

type InternalConfig

type InternalConfig struct {
	Database string
	Dsn      string
	// contains filtered or unexported fields
}

func Init

func Init(database string, config Config) (InternalConfig, error)

func (InternalConfig) Serve

func (config InternalConfig) Serve(port string, key string) error

func (InternalConfig) Watch

func (config InternalConfig) Watch(next func(http.ResponseWriter, *http.Request)) func(writer http.ResponseWriter, request *http.Request)

type Response

type Response struct {
	Message string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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