playground

package module
v0.0.0-...-3de4bba Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 29 Imported by: 0

README

fontseca.dev's playground

playground

A screenshot of the initial version of the fontseca.dev's playground running with a collection exported from Postman.

The fontseca.dev's playground is a web-based HTTP client designed for testing APIs. It was originally built with the intent to have a dedicated space to showcase my work as a back-end engineer, but it can be used with other third-party APIs.

Features

The Playground currently supports HTTP/1.1 servers and allows importing Postman collections in JSON format. It handles

The playground supports the following HTTP methods:

  • GET,
  • POST,
  • PUT,
  • PATCH,
  • and DELETE.

HTTP request features

  • Query parameters
  • HTTP headers
  • HTTP body

The HTTP request body is passed as a raw string, with content differentiated by the Content-Type header.

HTTP response features

  • Response body
  • HTTP headers
  • Cookies

Getting Started

To get started working with the Playground, clone this repository and simply run the application. You'll need to install the templ command to generate the website code.

By default, the Playground is intended to be used as a plug-in within a wrapper project. I use it as a Git submodule in my website's codebase. If you want to run it separately, you'll have to create a go.mod file.

  1. Clone the repository:

    git clone git@github.com:fontseca/playground.git
    cd playground/
    
  2. Generate the website.templ file:

    ~/go/bin/templ generate
    Processing path: /home/fontseca/playground
    (!) templ version check failed: failed to read go.mod file: open /go.mod: no such file or directory
    Generating production code: /home/fontseca/playground
    (✓) Generated code for "/home/fontseca/playground/website.templ" in 26.710246ms
    (✓) Generated code for 1 templates with 0 errors in 27.004517ms
    
  3. Start a Go module called playground:

    go mod init playground
    go mod tidy
    
  4. And finally, run the Playground:

    go run cmd/playground/main.go
    running fontseca.dev/playground server at 172.17.0.1:40273
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Renderer

func Renderer(w http.ResponseWriter, r *http.Request)

Renderer renders the website template and writes it to the HTTP response writer.

func Scanner

func Scanner(ctx context.Context, w http.ResponseWriter, r *http.Request)

Scanner scans an incoming HTTP request, parses it, sends it to the backend, and writes the formatted response to the HTTP response writer.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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