Giter Club home page Giter Club logo

otter's Introduction

otter

Otter is a micro web framework that sits on top of the servlet api 4.0.1

Contribute!

Contribute!

Hello World Application

If you want to get started with all the details head over to the hello world example application.

Quick Start Application

If you want to get started quickly head over to the quick start example application. Only 5 files to get started.

Dependency coordinates

Latest pinned version is 1.5.7

Current development version is 1.5.7

Maven

<dependencies>
    <dependency>
        <groupId>net.tokensmith</groupId>
        <artifactId>otter</artifactId>
        <version>1.5.7</version>
    </dependency>
</dependencies>

Gradle

compile group: 'net.tokensmith', name: 'otter', version: '1.5.7'

Documentation

Detailed documentation is available.

Why?

Otter was created to provide these features:

  • Preference of Generics over Reflection
  • Abstract the I/O framework from the web framework
  • Regex routing
  • Application encrypted sessions
  • Async I/O
  • HTTP 2

Otter began embedded within a web application in late 2014. Back then there were not many options for those features. It was extracted and open sourced in 2017.

otter's People

Contributors

tmackenzie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

otter's Issues

optional session before

DecryptSession requires a session to continue the request.

Write a Optional DecryptSession that would only read and decrypt the session if its there, else it just continues.

This would be used for resources that would optionally render user's content if they were logged in.

exception to handler

Betweens or Resources should be able to throw an Exception or return an Either that would result in a error handler being executed. These would be for any status code.

  • 401, 403, etc.

Candidate is add, statusCode to HaltException.

Add groups

Allow groups to be added without adding a target. This reduce target builder methods.

payload routing

Given a post request with a request body
When the request body contains data the will help route the request
Then the dispatcher should inspect the request body to determine how to route the request.

plain text session

Allow the ability to use plain text sessions via:

  • Unsecured JWT
  • Secured JWT (signed)

Handle Dispatch Errors

Dispatch Errors that occur in engine

  • When a ask's url is not found.
  • When a ask has a invalid content-type
  • 404, 415, ...

Given a request
with the header Content-Type: application/json
When the url is matched and it expects Content-Type: application/json; charset=utf-8
Then add the header X-Reasons which is a unsecure jwt with the payload

[
  {
    "k": "Content-Type",
    "v": "application/json",
    "src": "hdr", 
    "exp": ["application/json; charset=utf-8"], 
    "msg": ""
  },
]

And set the status code to 415
And dispatch the request to a configured Unsupported Media Type Route.

url parameter routing.

Given a request url with url parameters
When the url parameters help to determine which resource should handle the request
Then the dispatcher should look at the url parameters for routing.

packaging

At the moment building a executable war works with one limitation.

I have noticed that if there is the possibility of namespace collision for packaged files. This prevents starting the application via the executable war . I've beeb able to get around this issue by doing the following in a project's war task, `exclude "path/to/file.txt". This can only be done for files that are not needed, such as text files.

Package the war file to eliminate namespace collision modify the class path so jetty knows how to find everything.

HTML and Rest should have different implementations.

Ultimately there should be a HtmlResource and RestResource which do not extend a base class from one another.

Will have separe paths to configure the application.
Will have two interfaces to add a target, HTML and Rest.

Will require unique:

  • Request
  • Response
  • Between
  • Betweens
  • LocationTranslators
  • Route
  • Resource
  • Target
  • Group
  • Global Errors may need to be deprecated because otter wont know if it was a Rest or Html Ask.

Maven Publish Plugin

Use the Maven Publish Plugin with gradle to publish artifacts to maven central

Configure

The entry servlet should delegate configuration and routes via a Configure.

public interface Configure {
    void configure(Gateway gateway);
    void routes(Gateway gateway);
}

RestResource payload to generic type

Given a Request
When its routed to a RestResource
Then the Request and Response should have a ivar payload
And the payload's data type is a Java class that represents it's shape

Unchecked casts

Review unchecked casts and see if they can be checked.
Culprits are shown in build.

prefer coordinate error route.

Given the Engine
When a not found, unsupported media type, or unexpected exception occurs
And the coordinate has the appropriate error route
Then execute the the coordinate's error route.

NPE in ReadListener

ReadListener can throw a NPE when either are null:

  • gatewayResponse.getPayload()
  • gatewayResponse.getTemplate()

Then the AsyncContext never completes.

jdk12

upgrade to jdk 12 and gradle 5.5

content type routing

Resources should be able to specify the content types it accepts.
If a request fails to validate then return a 415 unsupported media type.

CSRF - Sign form value.

Given XSS
When I attempt to make a request to another url
And I have access to CSRF cookie
And I don't have access to form input value
Then prevent the request via CSRF protection.

Unable to protect
XSS same page attacks cannot be protected.
Because attacker has access to cookie and form value.

Handle Framework errors

Framework Errors

  • Unexpected errors that occur in the Otter Framework.
  • 500

These will require configuring the underlying i/o framework.

Error Handling.

Processing Errors

  • Currently in RouteRun
  • RuntimeException from a Resource
  • 400, 500, ...

Label for authentication between

When adding groups
Then allow a custom authentication between to be assigned to that group.

When the label for authentication is used
Then reference that groups authentication between.

Two labels are needed, required and optional.

gateway to return route.

When a resource is registered with the gateway
Then return it's route.

This feature will allow modifying the before or after betweens configure.

scaffold projects

Implement a way to auto scaffold a project.
Maybe through a gradle plugin?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.