A streamlined and powerful golang framework

Related tags

Web Frameworks sw
Overview

SW: A simple web Framework


sw try to use the official library as much as possible

step 1. Hello World

    app := sw.NewApp()
    app.GET("/hello1", func(this *sw.This) {
        data := sw.M{
            "hello": "world",
        }
        this.Json(http.StatusOK, data)
    })
    if err := app.Run(":8999"); err != nil {
        log.Println(err.Error())
    }

step 2. Use routing group

    app := sw.NewApp()
    group1 := app.Group("/test1/")
    {
        group1.GET("/hello1", func(this *sw.This) {
            data := sw.M{
                "hello": "world",
            }
            this.Json(http.StatusOK, data)
        })
    }
    if err := app.Run(":8999"); err != nil {
        log.Println(err.Error())
    }

step 3. Cross domain -> using built-in middleware

    app := sw.NewApp()
    app.Use(sw.Cors()).GET("/hello1", func(this *sw.This) {
        data := sw.M{
            "hello": "world",
        }
        this.Json(http.StatusOK, data)
    })
    if err := app.Run(":8999"); err != nil {
        log.Println(err.Error())
    }

step 4. Basic Auth -> using built-in middleware

    app := sw.NewApp()
    app.Use(sw.BasicAuth("abc","123")).GET("/hello1", func(this *sw.This) {
        data := sw.M{
            "hello": "world",
        }
        this.Json(http.StatusOK, data)
    })
    if err := app.Run(":8999"); err != nil {
        log.Println(err.Error())
    }

step 5. Support Vue -> using built-in routing

  • First, define public variables
//go:embed static/*
var Files embed.FS
  • using built-in routing
    app := sw.NewApp()
    app.VUE("./static", &Files)
    if err := app.Run(":8999"); err != nil {
        log.Println(err.Error())
    }

step 6. Get routing parameters

    app := sw.NewApp()
    app.GET("/users/:name", func(this *sw.This) {
        user := this.Param("name","zhang")
        this.Html(http.StatusOK, user)
    })
    if err := app.Run(":8999"); err != nil {
        log.Println(err.Error())
    }

step 7. "GET" parameters

    app := sw.NewApp()
    app.GET("/list", func(this *sw.This) {
        pg := this.Path("page","1")
        this.Html(http.StatusOK, pg)
    })
    if err := app.Run(":8999"); err != nil {
        log.Println(err.Error())
    }

  • testing
curl http://localhost:8999/list?page=2

step 8. "POST" parameters(form)

    app := sw.NewApp()
    app.POST("/new-user", func(this *sw.This) {
        param := Param1{}
        if err := this.ParseForm(&param); err != nil {
            log.Println(err)
        }
        this.Json(http.StatusOK, param)
    })
    if err := app.Run(":8999"); err != nil {
        log.Println(err.Error())
    }

step 9. "POST" parameters(json)

    app := sw.NewApp()
    app.POST("/new-user", func(this *sw.This) {
        param := Param1{}
        if err := this.ParseJson(&param); err != nil {
            log.Println(err)
        }
        this.Json(http.StatusOK, param)
    })
    if err := app.Run(":8999"); err != nil {
        log.Println(err.Error())
    }
Releases(v1.0.2)
Owner
熊建波
熊建波
A powerful go web framework for highly scalable and resource efficient web application

webfr A powerful go web framework for highly scalable and resource efficient web application Installation: go get -u github.com/krishpranav/webfr Exa

Krisna Pranav 13 Nov 28, 2021
A powerful go web framework for highly scalable and resource efficient web application

A powerful go web framework for highly scalable and resource efficient web application

null 20 Feb 2, 2022
skr: The lightweight and powerful web framework using the new way for Go.Another go the way.

skr Overview Introduction Documents Features Install Quickstart Releases Todo Pull Request Issues Thanks Introduction The lightweight and powerful web

go-the-way 1 Jan 11, 2022
Best simple, lightweight, powerful and really fast Api with Golang (Fiber, REL, Dbmate) PostgreSqL Database and Clean Architecture

GOLANG FIBER API (CLEAN ARCHITECTURE) Best simple, lightweight, powerful and really fast Api with Golang (Fiber, REL, Dbmate) PostgreSqLDatabase using

Elias Champi 1 Apr 27, 2022
A very simple and powerful package for making REST requests with very little effort

Welcome to KRest KRest stands for Keep it simple REST Package. It's a very simple and powerful package wrapper over the standard http package for maki

Vinícius Garcia 3 Dec 14, 2021
Flamingo Framework and Core Library. Flamingo is a go based framework for pluggable web projects. It is used to build scalable and maintainable (web)applications.

Flamingo Framework Flamingo is a web framework based on Go. It is designed to build pluggable and maintainable web projects. It is production ready, f

Flamingo 295 May 7, 2022
laravel for golang,goal,fullstack framework,api framework

laravel for golang,goal,fullstack framework,api framework

桥边红药 17 Feb 24, 2022
Golanger Web Framework is a lightweight framework for writing web applications in Go.

/* Copyright 2013 Golanger.com. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except

golanger 299 Mar 3, 2022
The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework.

jin About The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework. If thi

null 8 Dec 27, 2021
REST api using fiber framework written in golang and using firebase ecosystem to authentication, storage and firestore as a db and use clean architecture as base

Backend API Example FiberGo Framework Docs : https://github.com/gofiber Info This application using firebase ecosystem Firebase Auth Cloud Storage Fir

Atilla Pehlivan 2 Apr 17, 2022
Fast and Reliable Golang Web Framework

Gramework The Good Framework Gramework long-term testing stand metrics screenshot made with Gramework Stats Dashboard and metrics middleware What is i

null 368 Feb 13, 2022
Example Golang API backend rest implementation mini project Point Of Sale using Gin Framework and Gorm ORM Database.

Example Golang API backend rest implementation mini project Point Of Sale using Gin Framework and Gorm ORM Database.

Restu Wahyu Saputra 24 May 18, 2022
Bootstrapper and middleware for Echo framework in golang.

rk-echo Interceptor & bootstrapper designed for echo framework. Currently, supports bellow functionalities. Name Description Start with YAML Start ser

PointGoal 4 Mar 31, 2022
Gerasimos (Makis) Maropoulos 22.3k May 16, 2022
henrylee2cn 1.6k May 17, 2022
Gin is a HTTP web framework written in Go (Golang).

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.

Gin-Gonic 58.9k May 15, 2022
BANjO is a simple web framework written in Go (golang)

BANjO banjo it's a simple web framework for building simple web applications Install $ go get github.com/nsheremet/banjo Example Usage Simple Web App

Nazarii Sheremet 19 Jan 24, 2022
A REST framework for quickly writing resource based services in Golang.

What is Resoursea? A high productivity web framework for quickly writing resource based services fully implementing the REST architectural style. This

Resoursea 32 Jan 24, 2022