bagoette

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 9 Imported by: 0

README

[Early Development 🛠️] BAGOETTE: Best Go RestfulAPI Library for Beginner 🥖

Teto want to say hello

yo whats up gng ✌️

So currently i'am trying to construct a Golang RestfulAPI library like gin, fiber and echo 🏗️ but... its specialized to help beginner to create their own Golang backend service.

yeah, i know the codes and the project structures are still really messy because i'm new to this Programming language🥀

so yeah maybe you guys can give me some advice?

documentation

installation

just give it a try dawg 🥖

go get github.com/sevelfatt/bagoette

hold on gng ✌️, i just started this project

Documentation

Index

Constants

View Source
const (
	Reset  = "\033[0m"
	Red    = "\033[31m"
	Green  = "\033[32m"
	Yellow = "\033[33m"
	Blue   = "\033[34m"
	White  = "\033[37m"
)

Variables

View Source
var RequestStatusColours = map[int]string{
	1: Blue,
	2: Green,
	3: Blue,
	4: Yellow,
	5: Red,
}

Functions

func Log

func Log(message string)

Types

type BagoetteClient

type BagoetteClient struct {
	Opts *Options
	// contains filtered or unexported fields
}

Bagoette main struct: work as the core of the library and provide all the features like router, middleware, context, etc

func NewClient

func NewClient() *BagoetteClient

NewClient: create a new BagoetteClient

func (*BagoetteClient) Close

func (b *BagoetteClient) Close() error

func (*BagoetteClient) GetHTTPHandler

func (b *BagoetteClient) GetHTTPHandler() *http.ServeMux

func (*BagoetteClient) GetRoutes

func (b *BagoetteClient) GetRoutes() []Route

func (*BagoetteClient) InternalServerErrorMiddleware

func (b *BagoetteClient) InternalServerErrorMiddleware(c *Ctx)

func (*BagoetteClient) MaxUploadSize added in v0.4.0

func (b *BagoetteClient) MaxUploadSize(size int64) *BagoetteClient

MaxUploadSize: set the max upload size of the server

func (*BagoetteClient) MethodNotAllowedMiddleware

func (b *BagoetteClient) MethodNotAllowedMiddleware(c *Ctx)

func (*BagoetteClient) NewRouter

func (b *BagoetteClient) NewRouter() *RouteGroup

func (*BagoetteClient) NotFoundMiddleware

func (b *BagoetteClient) NotFoundMiddleware(c *Ctx)

func (*BagoetteClient) Port

func (b *BagoetteClient) Port(port int) *BagoetteClient

Port: set the port of the server

func (*BagoetteClient) Serve

func (b *BagoetteClient) Serve() error

func (*BagoetteClient) ServeAppearance

func (b *BagoetteClient) ServeAppearance()

func (*BagoetteClient) ShowRoutes

func (b *BagoetteClient) ShowRoutes()

type Ctx

type Ctx struct {
	// contains filtered or unexported fields
}

Context struct: work as the container of the request and response

func NewContext

func NewContext(opts *Options, writer http.ResponseWriter, request *http.Request, route *Route) *Ctx

func (*Ctx) Abort

func (c *Ctx) Abort() error

Abort: abort the request

func (*Ctx) Bind

func (c *Ctx) Bind(body any) error

Bind: bind the request body to a struct

func (*Ctx) Check

func (c *Ctx) Check() error

func (*Ctx) DownloadFile added in v0.4.2

func (c *Ctx) DownloadFile(path string) error

DownloadFile: Download a file

func (*Ctx) Error

func (c *Ctx) Error(status int, message string) error

Error: respond with an error

func (*Ctx) Get

func (c *Ctx) Get(key string) (any, error)

Get: get a value from the context data

func (*Ctx) GetAndSaveFiles added in v0.4.2

func (c *Ctx) GetAndSaveFiles(key string, path string) error

func (*Ctx) GetFiles added in v0.4.2

func (c *Ctx) GetFiles(key string) ([]*multipart.FileHeader, error)

func (*Ctx) Header

func (c *Ctx) Header(key string) (string, error)

Header: get a header

func (*Ctx) Next

func (c *Ctx) Next() error

Next: call the next handler and reset the context after the last handler is called

func (*Ctx) Param

func (c *Ctx) Param(key string) (string, error)

Param: get a path parameter

func (*Ctx) Query

func (c *Ctx) Query(key string) (string, error)

Query: get a query parameter

func (*Ctx) Reset

func (c *Ctx) Reset() error

Reset: reset the context

func (*Ctx) Respond added in v0.4.2

func (c *Ctx) Respond(status int, data any) error

Responsd: respond with a JSON

func (*Ctx) RespondFile added in v0.4.2

func (c *Ctx) RespondFile(path string) error

RespondFile: Respond with a file

func (*Ctx) SaveFile added in v0.4.1

func (c *Ctx) SaveFile(file *multipart.FileHeader, path string) error

func (*Ctx) Set

func (c *Ctx) Set(key string, value any) error

Set: set a value in the context data

func (*Ctx) SetHeader

func (c *Ctx) SetHeader(key string, value string) error

SetHeader: set a header

type HandlerFunc

type HandlerFunc func(c *Ctx)

HandlerFunc type: Define the handler function that use bagoette context

type Options added in v0.4.0

type Options struct {
	Port          int
	MaxUploadSize int64
}

func NewOptions added in v0.4.0

func NewOptions() *Options

type Route

type Route struct {
	// contains filtered or unexported fields
}

Route struct: Define individual route

type RouteGroup added in v0.4.0

type RouteGroup struct {
	// contains filtered or unexported fields
}

Router struct: work as the router of the server

func (*RouteGroup) AddNewRouteToBagoetteClient added in v0.4.0

func (r *RouteGroup) AddNewRouteToBagoetteClient(route *Route)

func (*RouteGroup) Connect added in v0.4.0

func (r *RouteGroup) Connect(path string, handlers ...HandlerFunc)

func (*RouteGroup) Delete added in v0.4.0

func (r *RouteGroup) Delete(path string, handlers ...HandlerFunc)

func (*RouteGroup) Get added in v0.4.0

func (r *RouteGroup) Get(path string, handlers ...HandlerFunc)

func (*RouteGroup) Group added in v0.4.0

func (r *RouteGroup) Group(prefix string) *RouteGroup

func (*RouteGroup) Head added in v0.4.0

func (r *RouteGroup) Head(path string, handlers ...HandlerFunc)

func (*RouteGroup) NewRoute added in v0.4.0

func (r *RouteGroup) NewRoute(method string, path string, handlers []HandlerFunc)

func (*RouteGroup) Options added in v0.4.0

func (r *RouteGroup) Options(path string, handlers ...HandlerFunc)

func (*RouteGroup) Patch added in v0.4.0

func (r *RouteGroup) Patch(path string, handlers ...HandlerFunc)

func (*RouteGroup) Post added in v0.4.0

func (r *RouteGroup) Post(path string, handlers ...HandlerFunc)

func (*RouteGroup) Put added in v0.4.0

func (r *RouteGroup) Put(path string, handlers ...HandlerFunc)

func (*RouteGroup) Trace added in v0.4.0

func (r *RouteGroup) Trace(path string, handlers ...HandlerFunc)

func (*RouteGroup) Use added in v0.4.0

func (r *RouteGroup) Use(handlers ...HandlerFunc) *RouteGroup

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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