celeritas

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

Celeritas

Go Reference

This repo and package are for the Let's Build a Go version of Laravel course on Udemy.

I created a full package because I was having trouble with the go get command. I wanted to make sure that the package was available to everyone.

License

This project is licensed under the terms of the Apache License 2.0.

Documentation

Index

Constants

View Source
const (
	Version = "1.0.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Celeritas added in v1.3.0

type Celeritas struct {
	AppName  string
	Debug    bool
	Version  string
	ErrorLog *log.Logger
	InfoLog  *log.Logger
	RootPath string
	Routes   *chi.Mux
	// contains filtered or unexported fields
}

Celeritas is the main application struct

func (*Celeritas) CreateDirIfNotExist added in v1.3.0

func (c *Celeritas) CreateDirIfNotExist(path string) error

CreateDirIfNotExist takes a path string and returns an error. It creates the directory if it does not exist.

func (*Celeritas) CreateFileIfNotExists added in v1.3.0

func (c *Celeritas) CreateFileIfNotExists(path string) error

CreateFileIfNotExists creates a new empty file at the specified path if one doesn't exist. If the file already exists, it does nothing and returns nil. The created file is automatically closed after creation. It returns an error if the file creation fails.

func (*Celeritas) Init added in v1.3.0

func (c *Celeritas) Init(p initPaths) error

Init takes a initPaths and returns an error

func (*Celeritas) ListenAndServe added in v1.3.0

func (c *Celeritas) ListenAndServe()

ListenAndServe starts and runs the HTTP server until it encounters an error. It configures the server with:

  • Idle timeout of 30 seconds
  • Read timeout of 30 seconds
  • Write timeout of 600 seconds

The server listens on the port specified in the application config. If the server encounters an error during startup or operation, it logs the error and terminates the application.

func (*Celeritas) New added in v1.3.0

func (c *Celeritas) New(rootPath string) error

New returns a new Celeritas application

func (*Celeritas) StartLoggers added in v1.3.0

func (c *Celeritas) StartLoggers() (*log.Logger, *log.Logger)

StartLoggers initializes the application's logging system with two loggers: an InfoLog for general information (in green) and an ErrorLog for error messages (in red). Both loggers write to standard output with different prefixes, formats, and colors. It returns two loggers for info and error logging respectively.

Directories

Path Synopsis
Package inital contains initial code for the celeritas project
Package inital contains initial code for the celeritas project

Jump to

Keyboard shortcuts

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