rutar

module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: BSD-2-Clause

README

Rutar

Rutar is a Golang package for quickly setting up an HTTP service in a new project. It uses the built-in Golang HTTP router. It does not implement a new router. It is meant to make bringing up an HTTP server easier.

NOTE: This requires Golang 1.22's router enhancements. Please see Routing Enhancements

Assist

Rutar provides a small package with common functionality HTTP operations as well as common testing interfaces.

Middleware

Rutar does not require a specific middleware signature. All routes are added with a http.Handler, allowing standard function chaining to be used.

OAUTH

A simple OAUTH Login Middleware is provided. Tokens are stored in encrypted cookies in the callers browser. Functionality uses the golang oauth2 library.

OAUTH Flow
  • Config sets up the OAUTH handlers to support the OAUTH flow for the OAUTH provider.
  • handler_oauth_start starts the OAUTH flow.
    • eg: This can be used as your /login handler
    • Retrieved with NewOAUTHStartHandler
  • handler_oauth_callback handles the callback from an OAUTH service.
    • eg: This can be used as your /callback or /oauth/ handler
    • Retrieved with NewOAUTHCallbackHandler
  • ExchangeCookie handles logins with encrypted token data stored in a cookie
    • Validates the stored token before returning an AuthHolder
  • ExchangeLoginHeader handles logins with encrypted token data stored in an Authorization Header.
    • Validates the stored token before returning an AuthHolder
  • Returned AuthHolders can be used to return a client that is used to communicate with endpoints requiring OAUTH2 authentication / authorization. They also provide functionality to encrypt the refreshed OAUTH2 token so it can be returned to the caller for later use.

OPTIONS

Rutar does provide creation of OPTIONS handlers for routes. This is an optional step.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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